int RaptorServer::Start( std::string name ) { Data.Properties["name"] = name; if( IsRunning() ) { Net.SendAllReconnect(); StopAndWait(); SDL_Delay( 200 ); } Net.NetRate = NetRate; Net.UseOutThreads = UseOutThreads; if( !( Thread = SDL_CreateThread( RaptorServerThread, this ) ) ) { fprintf( stderr, "SDL_CreateThread: %s\n", SDLNet_GetError() ); return -1; } State = Raptor::State::CONNECTED; Started(); return 0; }
RAD_Thread::~RAD_Thread() { // this is an undetached thread, it would be reset after join if(m_handle) { radlog(L_WARN|L_CONS, "[RAD_Thread] dtor called, " "but thread '%s' is still running, forced stop", m_ThreadName.c_str()); StopAndWait(0); } }
RaptorServer::~RaptorServer() { if( IsRunning() ) StopAndWait( 5. ); if( Thread ) { // FIXME: This is causing crashing sometimes! // Probably when SDLNet_Quit() has already been called. SDL_KillThread( Thread ); Thread = NULL; } }
Reactor::~Reactor() { //Wait the termination of the thread StopAndWait(); }