diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-08-31 18:01:21 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-08-31 18:01:21 -0400 |
commit | 283e8d5bc00c13f821c67ed7a431af4bd7694113 (patch) | |
tree | 88e6c081d4d50ec7bc0bef59cf4306d2eabefb74 /controller/EmbeddedNetworkController.cpp | |
parent | f39e2e2a53f3f521b79d06681b859c7d9f4f80ca (diff) | |
download | infinitytier-283e8d5bc00c13f821c67ed7a431af4bd7694113.tar.gz infinitytier-283e8d5bc00c13f821c67ed7a431af4bd7694113.zip |
Start threads in Central harnessed mode.
Diffstat (limited to 'controller/EmbeddedNetworkController.cpp')
-rw-r--r-- | controller/EmbeddedNetworkController.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index 8d5febd9..1d46d5e6 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -434,6 +434,8 @@ EmbeddedNetworkController::EmbeddedNetworkController(Node *node,const char *dbPa _db(dbPath,this), _node(node) { + if ((dbPath[0] == '-')&&(dbPath[1] == 0)) + _startThreads(); // start threads now in Central harnessed mode } EmbeddedNetworkController::~EmbeddedNetworkController() @@ -1721,4 +1723,18 @@ void EmbeddedNetworkController::_request( _sender->ncSendConfig(nwid,requestPacketId,identity.address(),*(nc.get()),metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,0) < 6); } +void EmbeddedNetworkController::_startThreads() +{ + Mutex::Lock _l(_threads_m); + if (_threads.size() == 0) { + long hwc = (long)std::thread::hardware_concurrency(); + if (hwc < 1) + hwc = 1; + else if (hwc > 16) + hwc = 16; + for(long i=0;i<hwc;++i) + _threads.push_back(Thread::start(this)); + } +} + } // namespace ZeroTier |