void* JackPosixThread::ThreadHandler(void* arg) { JackPosixThread* obj = (JackPosixThread*)arg; JackRunnableInterface* runnable = obj->fRunnable; int err; if ((err = pthread_setcanceltype(obj->fCancellation, NULL)) != 0) { jack_error("pthread_setcanceltype err = %s", strerror(err)); } // Signal creation thread when started with StartSync jack_log("JackPosixThread::ThreadHandler : start"); obj->fStatus = kIniting; // Call Init method if (!runnable->Init()) { jack_error("Thread init fails: thread quits"); return 0; } obj->fStatus = kRunning; // If Init succeed, start the thread loop bool res = true; while (obj->fStatus == kRunning && res) { res = runnable->Execute(); } jack_log("JackPosixThread::ThreadHandler : exit"); pthread_exit(0); return 0; // never reached }
void* JackAndroidThread::ThreadHandler(void* arg) { sigset_t sigmask; sigemptyset(&sigmask); /* to zero out all bits */ sigaddset(&sigmask, SIGUSR1); /* to unblock SIGUSR1 */ pthread_sigmask(SIG_UNBLOCK, &sigmask, (sigset_t *)0); JackAndroidThread* obj = (JackAndroidThread*)arg; JackRunnableInterface* runnable = obj->fRunnable; int err; // Signal creation thread when started with StartSync jack_log("JackAndroidThread::ThreadHandler : start"); obj->fStatus = kIniting; // Call Init method if (!runnable->Init()) { jack_error("Thread init fails: thread quits"); return 0; } obj->fStatus = kRunning; // If Init succeed, start the thread loop bool res = true; while (obj->fStatus == kRunning && res) { res = runnable->Execute(); } jack_log("JackAndroidThread::ThreadHandler : exit"); pthread_exit(0); return 0; // never reached }
DWORD WINAPI JackWinThread::ThreadHandler(void* arg) { JackWinThread* obj = (JackWinThread*)arg; JackRunnableInterface* runnable = obj->fRunnable; // Signal creation thread when started with StartSync jack_log("JackWinThread::ThreadHandler : start"); obj->fStatus = kIniting; // Call Init method if (!runnable->Init()) { jack_error("Thread init fails: thread quits"); return 0; } obj->fStatus = kRunning; // If Init succeed, start the thread loop bool res = true; while (obj->fStatus == kRunning && res) { res = runnable->Execute(); } SetEvent(obj->fEvent); jack_log("JackWinThread::ThreadHandler : exit"); return 0; }