Try factoring out a mutex to see if its faster.

This commit is contained in:
Adam Ierymenko 2020-11-17 15:48:15 -05:00
parent 2fcc344299
commit 982c32322b
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
2 changed files with 32 additions and 15 deletions

View file

@ -28,6 +28,9 @@
#include "EthernetTap.hpp"
#include "BlockingQueue.hpp"
#define ZT_BUFFER_POOL_SIZE 64
#define ZT_BUFFER_POOL_MASK 63U
namespace ZeroTier {
class LinuxEthernetTap : public EthernetTap
@ -73,7 +76,8 @@ private:
std::thread _tapReaderThread;
std::thread _tapProcessorThread;
std::mutex _buffers_l;
std::vector<void *> _buffers;
std::atomic<uintptr_t> _buffers[ZT_BUFFER_POOL_SIZE];
std::atomic<uintptr_t> _bufferReadPtr,_bufferWritePtr;
BlockingQueue< std::pair<void *,int> > _tapq;
};