From 49f031ccb4d518e8a715777f5d848759bae0def8 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 7 Apr 2015 19:31:11 -0700 Subject: Tons of refactoring, change to desperation algorithm to use max of core or link, porting over core loop code from old Node.cpp to new CAPI version, etc. --- node/Node.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'node/Node.hpp') diff --git a/node/Node.hpp b/node/Node.hpp index d6be609e..2de35fb3 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -62,7 +62,8 @@ public: ZT1_WirePacketSendFunction wirePacketSendFunction, ZT1_VirtualNetworkFrameFunction virtualNetworkFrameFunction, ZT1_VirtualNetworkConfigFunction virtualNetworkConfigFunction, - ZT1_StatusCallback statusCallback); + ZT1_StatusCallback statusCallback, + const char *overrideRootTopology); ~Node(); @@ -74,7 +75,7 @@ public: unsigned int linkDesperation, const void *packetData, unsigned int packetLength, - uint64_t *nextCallDeadline); + uint64_t *nextBackgroundTaskDeadline); ZT1_ResultCode processVirtualNetworkFrame( uint64_t now, uint64_t nwid, @@ -84,8 +85,8 @@ public: unsigned int vlanId, const void *frameData, unsigned int frameLength, - uint64_t *nextCallDeadline); - ZT1_ResultCode processBackgroundTasks(uint64_t now,uint64_t *nextCallDeadline); + uint64_t *nextBackgroundTaskDeadline); + ZT1_ResultCode processBackgroundTasks(uint64_t now,uint64_t *nextBackgroundTaskDeadline); ZT1_ResultCode join(uint64_t nwid); ZT1_ResultCode leave(uint64_t nwid); ZT1_ResultCode multicastSubscribe(uint64_t nwid,uint64_t multicastGroup,unsigned long multicastAdi); @@ -163,6 +164,8 @@ public: return nw; } + inline unsigned int coreDesperation() const throw() { return _coreDesperation; } + inline bool dataStorePut(const char *name,const void *data,unsigned int len,bool secure) { return (_dataStorePutFunction(reinterpret_cast(this),name,data,len,(int)secure) == 0); } inline bool dataStorePut(const char *name,const std::string &data,bool secure) { return dataStorePut(name,(const void *)data.data(),(unsigned int)data.length(),secure); } inline void dataStoreDelete(const char *name) { _dataStorePutFunction(reinterpret_cast(this),name,(const void *)0,0,0); } @@ -190,7 +193,13 @@ private: std::map< uint64_t,SharedPtr > _networks; Mutex _networks_m; - volatile uint64_t _now; // time of last run() + Mutex _backgroundTasksLock; + + uint64_t _now; + uint64_t _startTimeAfterInactivity; + uint64_t _lastPingCheck; + uint64_t _lastHousekeepingRun; + unsigned int _coreDesperation; unsigned int _newestVersionSeen[3]; // major, minor, revision }; -- cgit v1.2.3