From 792610d44fe009bad5a2792786cecc89e8e08b91 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant <“bsergean@gmail.com”> Date: Tue, 16 Apr 2019 18:21:52 -0700 Subject: [PATCH] use threads instead of std::async, need to cleanup threads --- ixwebsocket/IXSocketServer.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ixwebsocket/IXSocketServer.cpp b/ixwebsocket/IXSocketServer.cpp index c77c76be..94e30903 100644 --- a/ixwebsocket/IXSocketServer.cpp +++ b/ixwebsocket/IXSocketServer.cpp @@ -160,6 +160,8 @@ namespace ix // Return value of std::async, ignored std::future f; + std::vector threads; + for (;;) { if (_stop) return; @@ -231,11 +233,15 @@ namespace ix // // the destructor of a future returned by std::async blocks, // so we need to declare it outside of this loop - f = std::async(std::launch::async, - &SocketServer::handleConnection, - this, - clientFd, - connectionState); + // f = std::async(std::launch::async, + // &SocketServer::handleConnection, + // this, + // clientFd, + // connectionState); + threads.push_back(std::thread(&SocketServer::handleConnection, + this, + clientFd, + connectionState)); } } }