Пример #1
0
/**
* @brief   if there are some threads block in push or pop process, call this function can
* force all these threads to exit.
*
* @author hankejia
* @date 2012-07-05
* @param[in] pthis		the pointer point to the CCycBuffer.
* @return T_S32
* @retval return 0 for success, otherwise for failed
*/
static T_S32 ForceQuit( T_pVOID pthis )
{
    CCycBuffer *this = ( CCycBuffer * )pthis;
    CycBuffer_handle * handle = (CycBuffer_handle *)this->handle;

    Condition_Lock( handle->mDataCon );

    handle->mForceQuit = AK_TRUE;

    //Condition_Broadcast( &(handle->mWaitForPushCon) );
    //Condition_Broadcast( &(handle->mWaitForPopCon) );
    Condition_Broadcast( &(handle->mDataCon) );
    Condition_Unlock( handle->mDataCon );

    return 0;
}
Пример #2
0
/*
 * BarrierClient allows for multiple stream clients to be syncronized
 */
void BarrierClient( ReportHeader *agent ) {
    Condition_Lock(agent->multireport->barrier);
    agent->multireport->threads--;
    if ( agent->multireport->threads == 0 ) {
        // last one set time and wake up everyone
        gettimeofday( &(agent->multireport->startTime), NULL );
        Condition_Broadcast( &agent->multireport->barrier );
    } else {
        Condition_Wait( &agent->multireport->barrier );
    }
    agent->multireport->threads++;
    Condition_Unlock( agent->multireport->barrier );
    agent->report.startTime = agent->multireport->startTime;
    agent->report.nextTime = agent->report.startTime;
    TimeAdd( agent->report.nextTime, agent->report.intervalTime );
}