QTSSvrControlThread::~QTSSvrControlThread() { fDone = true; port_deallocate(task_self(), fMessagePort);//force SC thread to wakeup fMessagePort = 0; //wait for thread to terminate... these mach prototypes are very strange... //why, for instance, does thread_resume take an INT???? if (fThreadsAllocated) { thread_resume((unsigned int)fThreadID);//force a wakeup. cthread_join(fThreadID); thread_resume((unsigned int)fHistoryThreadID); cthread_join(fHistoryThreadID); } }
void cthread_release(cthread *tid) { cthread self; if (*tid == NULL) return; self = *tid; cthread_resume(tid); cthread_join(tid); #ifdef _WIN32 if (self->handle) CloseHandle(self->handle); if (self->event) CloseHandle(self->event); self->handle = NULL; self->event = NULL; #else pthread_cond_destroy(&self->cond); pthread_mutex_destroy(&self->mutex); #endif free(self); *tid = NULL; }
int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return ) { void *status; status = (void *) cthread_join ( thread ); if (thread_return != NULL) { *thread_return = status; } return 0; }
void OSThread::Join() { // What we're trying to do is allow the thread we want to delete to complete // running. So we wait for it to stop. Assert(!fJoined); fJoined = true; #ifdef __Win32__ DWORD theErr = ::WaitForSingleObject(fThreadID, INFINITE); Assert(theErr == WAIT_OBJECT_0); #elif __PTHREADS__ void *retVal; pthread_join((pthread_t)fThreadID, &retVal); #else cthread_join((cthread_t)fThreadID); #endif }