void NetGameServer::listen_thread_main() { while (true) { Event accept_event = impl->tcp_listen->get_accept_event(); int wakeup_reason = Event::wait(impl->stop_event, accept_event); if (wakeup_reason != 1) break; TCPConnection connection = impl->tcp_listen->accept(); std::unique_ptr<NetGameConnection> game_connection(new NetGameConnection(this, connection)); MutexSection mutex_lock(&impl->mutex); impl->connections.push_back(game_connection.release()); } }
void CL_NetGameServer::listen_thread_main() { while (true) { CL_Event accept_event = impl->tcp_listen->get_accept_event(); int wakeup_reason = CL_Event::wait(impl->stop_event, accept_event); if (wakeup_reason != 1) break; CL_TCPConnection connection = impl->tcp_listen->accept(); CL_AutoPtr<CL_NetGameConnection> game_connection(new CL_NetGameConnection(this, connection)); CL_MutexSection mutex_lock(&impl->mutex); impl->connections.push_back(game_connection.release()); } }
void NetGameServer::listen_thread_main() { while (true) { std::unique_lock<std::mutex> lock(impl->mutex); if (impl->stop_flag) break; NetworkEvent *events[] = { impl->tcp_listen.get() }; impl->worker_event.wait(lock, 1, events); SocketName peer_endpoint; TCPConnection connection = impl->tcp_listen->accept(peer_endpoint); if (!connection.is_null()) { std::unique_ptr<NetGameConnection> game_connection(new NetGameConnection(this, connection)); impl->connections.push_back(game_connection.release()); } } }