From 8e19188f49fe33679ebc565cd5f6d184e7b87842 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 2 May 2017 16:58:51 -0700 Subject: Do the sometimes rather big "pong" in a background worker thread. --- controller/EmbeddedNetworkController.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'controller/EmbeddedNetworkController.hpp') diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp index 0a6b8176..ade7eb20 100644 --- a/controller/EmbeddedNetworkController.hpp +++ b/controller/EmbeddedNetworkController.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "../node/Constants.hpp" @@ -103,11 +104,29 @@ private: InetAddress fromAddr; Identity identity; Dictionary metaData; + enum { + RQENTRY_TYPE_REQUEST = 0, + RQENTRY_TYPE_PING = 1 + } type; }; static void _circuitTestCallback(ZT_Node *node,ZT_CircuitTest *test,const ZT_CircuitTestReport *report); void _request(uint64_t nwid,const InetAddress &fromAddr,uint64_t requestPacketId,const Identity &identity,const Dictionary &metaData); + inline void _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