summaryrefslogtreecommitdiff
path: root/testnet/SimNetSocketManager.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-28 12:28:45 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-28 12:28:45 -0700
commitf873881a0ddf2043758b3e7925c95168600f42da (patch)
treee586d6e64ac07661362908b4e239d6c5c7578cc5 /testnet/SimNetSocketManager.hpp
parent934a575a7447bb34360e9f9f27dace971f811ce5 (diff)
downloadinfinitytier-f873881a0ddf2043758b3e7925c95168600f42da.tar.gz
infinitytier-f873881a0ddf2043758b3e7925c95168600f42da.zip
Helps to use a proper multithreaded queue instead of ugly plebian hackery.
Diffstat (limited to 'testnet/SimNetSocketManager.hpp')
-rw-r--r--testnet/SimNetSocketManager.hpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/testnet/SimNetSocketManager.hpp b/testnet/SimNetSocketManager.hpp
index df587072..a34728db 100644
--- a/testnet/SimNetSocketManager.hpp
+++ b/testnet/SimNetSocketManager.hpp
@@ -35,7 +35,8 @@
#include "../node/Constants.hpp"
#include "../node/SocketManager.hpp"
#include "../node/Mutex.hpp"
-#include "Semaphore.hpp"
+
+#include "MTQ.hpp"
namespace ZeroTier {
@@ -96,9 +97,7 @@ public:
*/
inline void enqueue(const InetAddress &from,const void *data,unsigned int len)
{
- Mutex::Lock _l(_inbox_m);
- _inbox.push_back(std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> >(from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN>(data,len)));
- _waitCond.signal();
+ _inbox.push(std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> >(from,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN>(data,len)));
}
virtual bool send(const InetAddress &to,bool tcp,bool autoConnectTcp,const void *msg,unsigned int msglen);
@@ -114,13 +113,10 @@ private:
SharedPtr<Socket> _mySocket;
TransferStats _totals;
- std::vector< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > > _inbox;
- Mutex _inbox_m;
+ MTQ< std::pair< InetAddress,Buffer<ZT_SOCKET_MAX_MESSAGE_LEN> > > _inbox;
std::map< InetAddress,TransferStats > _stats;
Mutex _stats_m;
-
- Semaphore _waitCond;
};
} // namespace ZeroTier