Esempio n. 1
0
/************************************************************************
* Function name:Stop
* Description  :停止事件循环
* IN           :NONE
* OUT          :NONE
* Return       :NONE
* Make By      :lqf/[email protected]
* Date Time    :2014/04/30
* Modification 
* ......record :first program
************************************************************************/
void CSockPairEvent::Stop(void)
{
    if (getIsRun())
    {
        m_Mutex.Lock();
        setRunStatus(RUNSTATUS_STOPPING);
        m_Cond.Wait(&m_Mutex);
        m_Mutex.unLock();
    }
}
Esempio n. 2
0
Q_SOCK CLog::addLoger(CLoger *pLoger)
{
    if (NULL == pLoger)
    {
        return Q_INVALID_SOCK;
    }

    if (!getIsRun())
    {
        Q_Printf("%s", "loger not run.");
        Q_SafeDelete(pLoger);

        return Q_INVALID_SOCK;
    }

    LogerInfo objLogInfo;

    objLogInfo.pLoger = pLoger;
    objLogInfo.pPair = new(std::nothrow) CSockPair();
    if (NULL == objLogInfo.pPair)
    {
        Q_Printf("%s", Q_EXCEPTION_ALLOCMEMORY);
        objLogInfo.FreeAll();

        return Q_INVALID_SOCK;
    }

    objLogInfo.pBuffer = new(std::nothrow) CEventBuffer();
    if (NULL == objLogInfo.pBuffer)
    {
        Q_Printf("%s", Q_EXCEPTION_ALLOCMEMORY);
        objLogInfo.FreeAll();

        return Q_INVALID_SOCK;
    }
    
    m_objMutex.Lock();
    int iRtn = sendMainMsg((const char*)(&objLogInfo), sizeof(objLogInfo));
    m_objMutex.unLock();
    if (Q_RTN_OK != iRtn)
    {
        Q_Printf("%s", "send message error");
        objLogInfo.FreeAll();

        return Q_INVALID_SOCK;
    }

    return objLogInfo.pPair->getWriteFD();
}