本文整理汇总了C++中CEvent::Wait方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::Wait方法的具体用法?C++ CEvent::Wait怎么用?C++ CEvent::Wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::Wait方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: am
//---------------------------------------------------------------------------
// @function:
// CSyncHashtableTest::Unittest_WaitTasks
//
// @doc:
// Waits until all others tasks have started
//
//---------------------------------------------------------------------------
void
CSyncHashtableTest::Unittest_WaitTasks
(
SElemTest *pelemtest
)
{
CEvent *pevent = pelemtest->Pevent();
CAutoMutex am(*(pevent->Pmutex()));
am.Lock();
// increase number of started tasks
pelemtest->IncStarted();
// wait if some other task has not started yet
if (pelemtest->UlStarted() < GPOS_SHT_THREADS)
{
pevent->Wait();
}
else
{
// wake up all waiting tasks
pevent->Broadcast();
}
}
示例2: OnStart
virtual bool OnStart()
{
if(m_pTcp)
m_pTcp->Start();
if(m_oDomainInfo.GetSize())
{
m_oEvent.Reset();
CRbTreeNode* pIt = m_oDomainInfo.First();
CRbTreeNode* pEnd = m_oDomainInfo.End();
for(; pIt!=pEnd; pIt=m_oDomainInfo.GetNext(pIt))
{
CAcmDomain& oDomain = m_oDomainInfo.GetItem(pIt);
if(oDomain.pSerialModule)
oDomain.pSerialModule->Start();
oDomain.pUdp->Start();
}
if(m_pTokenMoudle)
{
if(m_pVipModule && !m_pVipModule->Start())
return false;
m_pTokenMoudle->Start();
}
m_oEvent.Wait(3000);
if(m_bNodeRepeat)
return false;
}
return true;
}
示例3: Run
CStatus CThreadForMsgLoop::Run(void * pContext)
{
if(m_pThread == 0)
{
return CStatus(-1,0,"In CThreadForMsgLoop::Run : m_pThread is null");
}
CEvent event;
CThreadInitialFinishedNotifier notifier(&event);
SInitialParameter para;
para.pContext = pContext;
para.pNotifier = ¬ifier;
CStatus s_r = m_pThread->Run(¶);
if(!s_r.IsSuccess())
{
m_bWaitForDeath = false;
m_pThread = 0;
return CStatus(-1,0,"In CThreadForMsgLoop::Run invoke run failed!");
}
//主线程等待子线程初始化完毕
CStatus s_w = event.Wait();
if(!s_w.IsSuccess())
return s_w;
//判断子线程初始化是否成功
if(!notifier.IsInitialSuccess())
return CStatus(-1,0,"In CThreadForMsgLoop::Run : Thread initial failed");
else
return CStatus(0,0);
}
示例4: PowerOnTV
bool PowerOnTV(uint64_t iTimeout = 60000)
{
cec_power_status currentTvPower(CEC_POWER_STATUS_UNKNOWN);
uint64_t iNow = GetTimeMs();
uint64_t iTarget = iNow + iTimeout;
if (currentTvPower != CEC_POWER_STATUS_ON)
{
currentTvPower = g_parser->GetDevicePowerStatus(CECDEVICE_TV);
if (currentTvPower != CEC_POWER_STATUS_ON)
{
PrintToStdOut("Sending 'power on' command to the TV\n=== Please wait ===");
g_parser->PowerOnDevices(CECDEVICE_TV);
while (iTarget > iNow)
{
g_responseEvent.Wait((uint32_t)(iTarget - iNow));
if (g_lastCommand == CEC_OPCODE_REQUEST_ACTIVE_SOURCE)
break;
iNow = GetTimeMs();
}
}
}
currentTvPower = g_parser->GetDevicePowerStatus(CECDEVICE_TV);
if (currentTvPower != CEC_POWER_STATUS_ON)
PrintToStdOut("Failed to power on the TV, or the TV does not respond properly");
return currentTvPower == CEC_POWER_STATUS_ON;
}
示例5: t
TEST(TestThreadLocal, Simple)
{
GlobalThreadLocal runnable;
thread t(runnable);
gate.Wait();
EXPECT_TRUE(runnable.waiting);
EXPECT_TRUE(staticThinggy != NULL);
EXPECT_TRUE(staticThreadLocal.get() == NULL);
waiter.Set();
gate.Wait();
EXPECT_TRUE(runnable.threadLocalHadValue);
EXPECT_TRUE(!destructorCalled);
delete staticThinggy;
EXPECT_TRUE(destructorCalled);
cleanup();
}
示例6: WaitForPreload
bool PreloadClip::WaitForPreload(PlayListItem* pItem)
{
if (!pItem) return false;
CEvent syncEvent;
return m_pPreloadCmdProcessor->SetSyncComamnd(pItem, &syncEvent)
? syncEvent.Wait(TIME_INFINITY)
: false;
}
示例7: operator
inline void operator()()
{
staticThinggy = new Thinggy;
staticThreadLocal.set(staticThinggy);
waiting = true;
gate.Set();
waiter.Wait();
waiting = false;
threadLocalHadValue = staticThreadLocal.get() != NULL;
gate.Set();
}
示例8: WaitAllComplete
bool CThreadsPool::WaitAllComplete( CEvent& CancelEv )
{
LogStates();
m_mtTasks.Lock();
if( !m_vecTasks.empty() )
{
m_TasksEmpty.Reset();
m_mtTasks.Unlock();
Log::instance().Trace( 0, "CThreadsPool::WaitAllComplete: Wait for empty" );
for(;;)
{
if( m_TasksEmpty.Wait(0) )
break;
if( CancelEv.Wait(100) )
{
Log::instance().Trace( 0, "CThreadsPool::WaitAllComplete: canceled" );
return false;
}
}
} else
m_mtTasks.Unlock();
Log::instance().Trace( 0, "CThreadsPool::WaitAllComplete: Wait for complete" );
for( std::vector< SmartPtr<CEvent> >::iterator It = m_vecThreadsStates.begin(); It != m_vecThreadsStates.end(); It++ )
{
for(;;)
{
if( (*It)->Wait(0) )
break;
if( CancelEv.Wait(100) )
{
Log::instance().Trace( 0, "CThreadsPool::WaitAllComplete: canceled2" );
return false;
}
}
}
LogStates();
return true;
}
示例9: ThreadFunction
unsigned __stdcall ThreadFunction( void *pParam )
{
IClient *pClient = ( IClient * )pParam;
ASSERT( pClient );
while ( !m_theQuitThreadEvent.Wait( 0 ) )
{
size_t dataLength = 0;
const void *pData = pClient->GetPackFromServer( dataLength );
if ( !pData || 0 == dataLength )
{
Sleep( 1 );
continue;
}
EXTEND_HEADER* pHeader = (EXTEND_HEADER*)pData;
if (pHeader->ProtocolFamily == pf_relay)
{
if (pHeader->ProtocolID == relay_c2c_data)
{
RELAY_DATA* pRelayCmd = (RELAY_DATA*)pData;
in_addr ia;
ia.s_addr = pRelayCmd->nFromIP;
cout << "relaydata: " << inet_ntoa(ia) << '(' << pRelayCmd->nFromRelayID << ')' << " -- recv size: " << dataLength << endl;
}
if (pHeader->ProtocolID == relay_s2c_loseway)
{
RELAY_DATA* pRelayCmd = (RELAY_DATA*)pData;
in_addr ia;
ia.s_addr = pRelayCmd->nFromIP;
cout << "loseway: " << inet_ntoa(ia) << '(' << pRelayCmd->nFromRelayID << ')' << " -- recv size: " << dataLength << endl;
}
}
}
cout << "The read thread was killed safely!" << endl;
m_theAfirmThreadQuitEvent.Set();
return 0;
}