Example #1
0
int
tmsleep(time_t sec, time_t nsec)
{
	Tv_t	tv;

	tv.tv_sec = sec;
	tv.tv_nsec = nsec;
	return tvsleep(&tv, NiL);
}
Example #2
0
int CMessageService::svc(void)
{
    ACE_Message_Block* mb = NULL;

    //稍微休息一下,等一下其他线程再如主循环
    ACE_Time_Value tvSleep(0, MAX_MSG_SENDCHECKTIME*MAX_BUFF_1000);
    ACE_OS::sleep(tvSleep);

    while(IsRun())
    {
        mb = NULL;

        //xtime = ACE_OS::gettimeofday() + ACE_Time_Value(0, MAX_MSG_PUTTIMEOUT);
        if(getq(mb, 0) == -1)
        {
            OUR_DEBUG((LM_ERROR,"[CMessageService::svc] PutMessage error errno = [%d].\n", errno));
            m_blRun = false;
            break;
        }

        if(mb == NULL)
        {
            continue;
        }

        while(m_emThreadState != THREAD_RUN)
        {
            //如果模块正在卸载或者重载,线程在这里等加载完毕(等1ms)。
            ACE_Time_Value tvsleep(0, 1000);
            ACE_OS::sleep(tvsleep);
        }

        CMessage* msg = *((CMessage**)mb->base());

        if(! msg)
        {
            OUR_DEBUG((LM_ERROR,"[CMessageService::svc] mb msg == NULL CurrthreadNo=[%d]!\n", m_u4ThreadID));
            continue;
        }

        this->ProcessMessage(msg, m_u4ThreadID);

		//使用内存池,这块内存不必再释放
    }

    OUR_DEBUG((LM_INFO,"[CMessageService::svc] svc finish!\n"));
    return 0;
}