ixwebsocket/IXSocketServer.cpp
//
// join the threads for connections that have been closed
//
// When a connection is closed by a client, the connection state terminated
// field becomes true, and we can use that to know that we can join that thread
// and remove it from our _connectionsThreads data structure (a list).
//
join the threads for connections that have been closed
When a connection is closed by a client, the connection state terminated
field becomes true, and we can use that to know that we can join that thread
and remove it from our _connectionsThreads data structure (a list).
join the threads for connections that have been closed When a connection is closed by a client the connection state terminated field becomes true and we can use that to know that we can join that thread and remove it from our _connectionsThreads data structure ( a list ) .
void SocketServer::closeTerminatedThreads()
    {
        std::lock_guard<std::mutex> lock(_connectionsThreadsMutex);
        auto it = _connectionsThreads.begin();
        auto itEnd = _connectionsThreads.end();
        while (it != itEnd)
        {
            auto& connectionState = it->first;
            auto& thread = it->second;
            if (!connectionState->isTerminated())
            {
                ++it;
                continue;
            }
            if (thread.joinable()) thread.join();
            it = _connectionsThreads.erase(it);
        }
    }
void SocketServer :: closeTerminatedThreads ( ) { std :: lock_guard < std :: mutex > lock ( _connectionsThreadsMutex ) ; auto it = _connectionsThreads . begin ( ) ; auto itEnd = _connectionsThreads . end ( ) ; while ( it != itEnd ) { auto & connectionState = it -> first ; auto & thread = it -> second ; if ( ! connectionState -> isTerminated ( ) ) { ++ it ; continue ; } if ( thread . joinable ( ) ) thread . join ( ) ; it = _connectionsThreads . erase ( it ) ; } }
join the threads for connections that have been closed
When a connection is closed by a client, the connection state terminated
field becomes true, and we can use that to know that we can join that thread
and remove it from our _connectionsThreads data structure (a list).
join the threads for connections that have been closed When a connection is closed by a client the connection state terminated field becomes true and we can use that to know that we can join that thread and remove it from our _connectionsThreads data structure ( a list ) .