void rathread_destroy(rAthread *handle) { #ifdef WIN32 if( TerminateThread(handle->hThread, 0) != FALSE){ CloseHandle(handle->hThread); rat_thread_terminated(handle); } #else if( pthread_cancel( handle->hThread ) == 0){ // We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread. pthread_join( handle->hThread, NULL ); // Tell our manager to release resources ;) rat_thread_terminated(handle); } #endif }//end: rathread_destroy()
DWORD WINAPI _raThreadMainRedirector(LPVOID p){ #else static void *_raThreadMainRedirector( void *p ){ sigset_t set; // on Posix Thread platforms #endif void *ret; // Update myID @ TLS to right id. #ifdef HAS_TLS g_rathread_ID = ((rAthread)p)->myID; #endif #ifndef WIN32 // When using posix threads // the threads inherits the Signal mask from the thread which's spawned // this thread // so we've to block everything we dont care about. sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); sigaddset(&set, SIGPIPE); pthread_sigmask(SIG_BLOCK, &set, NULL); #endif ret = ((rAthread)p)->proc( ((rAthread)p)->param ) ; #ifdef WIN32 CloseHandle( ((rAthread)p)->hThread ); #endif rat_thread_terminated( (rAthread)p ); #ifdef WIN32 return (DWORD)ret; #else return ret; #endif }//end: _raThreadMainRedirector()