Esempio n. 1
0
void * IThread::threadfunc( void * arg )
{
    IThread * thread = (IThread *)arg;

    sigset_t mask;
    sigfillset(&mask);
    pthread_sigmask(SIG_SETMASK, &mask, NULL);

    // 线程开始
    if ( thread->onStart() )
    {
        while ( thread->isRunning() )
        {
            thread->onExecute();
        }
    }

    // 线程停止了
    thread->onStop();

    // 通知调用者, 线程已经停止了
    thread->notify();

    return NULL;
}