/* ======================== idSysThread::~idSysThread ======================== */ idSysThread::~idSysThread() { StopThread( !forceStop ); if( threadHandle ) { Sys_DestroyThread( threadHandle ); } }
/* ======================== idSysThread::WaitForThread ======================== */ void idSysThread::WaitForThread() { if( isWorker ) { signalWorkerDone.Wait( idSysSignal::WAIT_INFINITE ); } else if( isRunning ) { Sys_DestroyThread( threadHandle ); threadHandle = 0; } }
/* ======================== idSysThread::StartThread ======================== */ bool idSysThread::StartThread( const char* name_, core_t core, xthreadPriority priority, int stackSize ) { if( isRunning ) { return false; } name = name_; isTerminating = false; if( threadHandle ) { Sys_DestroyThread( threadHandle ); } threadHandle = Sys_CreateThread( ( xthread_t )ThreadProc, this, priority, name, core, stackSize, false ); isRunning = true; return true; }
/* ================ Posix_Exit ================ */ void Posix_Exit(int ret) { if ( tty_enabled ) { Sys_Printf( "shutdown terminal support\n" ); if ( tcsetattr( 0, TCSADRAIN, &tty_tc ) == -1 ) { Sys_Printf( "tcsetattr failed: %s\n", strerror( errno ) ); } } // at this point, too late to catch signals Posix_ClearSigs(); if ( asyncThread.threadHandle ) { Sys_DestroyThread( asyncThread ); } // process spawning. it's best when it happens after everything has shut down if ( exit_spawn[0] ) { Sys_DoStartProcess( exit_spawn, false ); } // in case of signal, handler tries a common->Quit // we use set_exit to maintain a correct exit code if ( set_exit ) { exit( set_exit ); } exit( ret ); }