use threads instead of std::async, need to cleanup threads
This commit is contained in:
parent
bcf2fc1812
commit
792610d44f
@ -160,6 +160,8 @@ namespace ix
|
|||||||
// Return value of std::async, ignored
|
// Return value of std::async, ignored
|
||||||
std::future<void> f;
|
std::future<void> f;
|
||||||
|
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (_stop) return;
|
if (_stop) return;
|
||||||
@ -231,11 +233,15 @@ namespace ix
|
|||||||
//
|
//
|
||||||
// the destructor of a future returned by std::async blocks,
|
// the destructor of a future returned by std::async blocks,
|
||||||
// so we need to declare it outside of this loop
|
// so we need to declare it outside of this loop
|
||||||
f = std::async(std::launch::async,
|
// f = std::async(std::launch::async,
|
||||||
&SocketServer::handleConnection,
|
// &SocketServer::handleConnection,
|
||||||
this,
|
// this,
|
||||||
clientFd,
|
// clientFd,
|
||||||
connectionState);
|
// connectionState);
|
||||||
|
threads.push_back(std::thread(&SocketServer::handleConnection,
|
||||||
|
this,
|
||||||
|
clientFd,
|
||||||
|
connectionState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user