当前位置: 首页>>代码示例>>C++>>正文


C++ CEvent::Wait方法代码示例

本文整理汇总了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();
	}
}
开发者ID:RalphSu,项目名称:gpos,代码行数:33,代码来源:CSyncHashtableTest.cpp

示例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;
	}
开发者ID:nightstyles,项目名称:focp,代码行数:28,代码来源:AcmService.cpp

示例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 = &notifier;

	CStatus s_r = m_pThread->Run(&para);
	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);
}
开发者ID:yinjingyu,项目名称:LinuxDevelopment,代码行数:33,代码来源:CThreadForMsgLoop.cpp

示例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;
}
开发者ID:Obruni,项目名称:libcec,代码行数:30,代码来源:cec-config.cpp

示例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();
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:17,代码来源:TestThreadLocal.cpp

示例6: WaitForPreload

bool PreloadClip::WaitForPreload(PlayListItem* pItem)
{
    if (!pItem) return false;
    CEvent syncEvent;
    return m_pPreloadCmdProcessor->SetSyncComamnd(pItem, &syncEvent)
           ? syncEvent.Wait(TIME_INFINITY)
           : false;
}
开发者ID:flyfire,项目名称:temp,代码行数:8,代码来源:PreloadClip.cpp

示例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();
  }
开发者ID:Foozle303,项目名称:xbmc,代码行数:12,代码来源:TestThreadLocal.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:exspecto-svn,代码行数:39,代码来源:ThreadsPool.cpp

示例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;
}
开发者ID:XeanoRRR,项目名称:mmo-resourse,代码行数:45,代码来源:testRelayServer.cpp


注:本文中的CEvent::Wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。