record workers in a map instead of a vector

This commit is contained in:
Benjamin Sergeant 2018-12-31 14:52:59 -08:00
parent ec2ad37860
commit cf340011e2
2 changed files with 3 additions and 4 deletions

View File

@ -114,7 +114,7 @@ namespace ix
continue; continue;
} }
_workers.push_back(std::thread(&WebSocketServer::handleConnection, this, clientFd)); _workers[clientFd] = std::thread(&WebSocketServer::handleConnection, this, clientFd);
} }
} }

View File

@ -8,7 +8,7 @@
#include <utility> // pair #include <utility> // pair
#include <string> #include <string>
#include <vector> #include <map>
#include <thread> #include <thread>
#include <functional> #include <functional>
@ -39,7 +39,6 @@ namespace ix
// socket for accepting connections // socket for accepting connections
int _serverFd; int _serverFd;
// FIXME: we never reclaim space in this array ... std::map<int, std::thread> _workers;
std::vector<std::thread> _workers;
}; };
} }