Revert "Tune thread count based on hardware concurrency."

This reverts commit 7b14aeb53e.
This commit is contained in:
Adam Ierymenko 2020-11-18 22:54:05 -05:00
parent 7b14aeb53e
commit a0c78da1ad
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
2 changed files with 7 additions and 7 deletions

View file

@ -184,14 +184,14 @@ LinuxEthernetTap::LinuxEthernetTap(
(void)::pipe(_shutdownSignalPipe); (void)::pipe(_shutdownSignalPipe);
for(unsigned int tn=0,tc=(unsigned int)std::thread::hardware_concurrency();tn<=tc;++tn) { for(unsigned int t=0;t<2;++t) {
_tapReaderThreads.push_back(std::thread([this, tn]{ _tapReaderThread[t] = std::thread([this, t]{
fd_set readfds,nullfds; fd_set readfds,nullfds;
int n,nfds,r; int n,nfds,r;
void *buf = nullptr; void *buf = nullptr;
std::vector<void *> buffers; std::vector<void *> buffers;
if (tn == 0) { if (t == 0) {
struct ifreq ifr; struct ifreq ifr;
memset(&ifr,0,sizeof(ifr)); memset(&ifr,0,sizeof(ifr));
strcpy(ifr.ifr_name,_dev.c_str()); strcpy(ifr.ifr_name,_dev.c_str());
@ -298,7 +298,7 @@ LinuxEthernetTap::LinuxEthernetTap(
} }
} }
} }
})); });
} }
_tapProcessorThread = std::thread([this] { _tapProcessorThread = std::thread([this] {
@ -331,8 +331,8 @@ LinuxEthernetTap::~LinuxEthernetTap()
::close(_shutdownSignalPipe[0]); ::close(_shutdownSignalPipe[0]);
::close(_shutdownSignalPipe[1]); ::close(_shutdownSignalPipe[1]);
for(std::vector<std::thread>::iterator t(_tapReaderThreads.begin());t!=_tapReaderThreads.end();++t) _tapReaderThread[0].join();
t->join(); _tapReaderThread[1].join();
_tapProcessorThread.join(); _tapProcessorThread.join();
for(std::vector<void *>::iterator i(_buffers.begin());i!=_buffers.end();++i) for(std::vector<void *>::iterator i(_buffers.begin());i!=_buffers.end();++i)

View file

@ -70,7 +70,7 @@ private:
int _fd; int _fd;
int _shutdownSignalPipe[2]; int _shutdownSignalPipe[2];
std::atomic_bool _enabled; std::atomic_bool _enabled;
std::vector<std::thread> _tapReaderThreads; std::thread _tapReaderThread[2];
std::thread _tapProcessorThread; std::thread _tapProcessorThread;
std::mutex _buffers_l; std::mutex _buffers_l;
std::vector<void *> _buffers; std::vector<void *> _buffers;