コード例 #1
0
ファイル: ServerLinker.cpp プロジェクト: CN-Zxcv/QService
int CServerLinker::Monitor(void)
{
    CServerLinkerMonitor *pMonitor = NULL;

    pMonitor = new(std::nothrow) CServerLinkerMonitor();
    if (NULL == pMonitor)
    {
        Q_Printf("%s", Q_EXCEPTION_ALLOCMEMORY);

        return Q_ERROR_ALLOCMEMORY;
    }

    pMonitor->setServerLinker(this);

    try
    {
        CThread objThread;

        //等待线程启动
        m_objMutex.Lock();
        objThread.Execute(pMonitor);
        m_objCond.Wait(&m_objMutex, 1000);
        m_objMutex.unLock();
    }
    catch (CException &e)
    {
        Q_SafeDelete(pMonitor);
        Q_Printf("exception code %d message %s", e.getErrorCode(), e.getErrorMsg());

        return e.getErrorCode();
    }

    return Q_RTN_OK;
}
コード例 #2
0
DWORD WINAPI CThread::ThreadProc(LPVOID lpParameter)
{
	   CThread *pThread = (CThread *)lpParameter;
	   if(pThread)
	      return pThread->Execute();
	   else
		  return (DWORD)-1;
}
コード例 #3
0
void *CThread::ThreadProc(void *obj)
{
      CThread *pThread = static_cast<CThread*>(obj);

      int canc = vlc_savecancel ();
      pThread->Execute();
      vlc_restorecancel (canc);

      return NULL;
}
コード例 #4
0
ファイル: xrThread.cpp プロジェクト: 2asoft/xray
void	CThread::startup(void* P)
{
	CThread* T = (CThread*)P;

	if (T->thMessages)	clMsg("* THREAD #%d: Started.",T->thID);
	FPU::m64r		();
	T->Execute		();
	T->thCompleted	= TRUE;
	if (T->thMessages)	clMsg("* THREAD #%d: Task Completed.",T->thID);
}
コード例 #5
0
ファイル: CThreadPool.cpp プロジェクト: RoelofBerg/fimreg
void CThreadPool::Execute(uint32_t CoreNo, ThreadEntryFct lpStartAddress, void* lpParameter)
{
	if((CoreNo+1) > THREAD_POOL_SIZE)
	{
		//Execute the last thread directly (on the core which is calling)
		lpStartAddress(lpParameter);
	}
	else
	{
		CThread* pThread = &mThreadList[CoreNo];
		pThread->Execute(lpStartAddress, lpParameter);
	}
}
コード例 #6
0
ファイル: AtmoThread.cpp プロジェクト: cmassiot/vlc-broadcast
void *CThread::ThreadProc(vlc_object_t *obj)
{
      atmo_thread_t *pAtmoThread = (atmo_thread_t *)obj;
      CThread *pThread = (CThread *)pAtmoThread->p_thread;
      if(pThread) {
         int canc;

         canc = vlc_savecancel ();
         pThread->Execute();
         vlc_restorecancel (canc);
      }
      return NULL;
}
コード例 #7
0
ファイル: ifc_thread.cpp プロジェクト: haoxingeng/ifc
//-----------------------------------------------------------------------------
// The thread execution procedure.
// Parameters:
//   pParam: Points to the CThread object.
//-----------------------------------------------------------------------------
UINT __stdcall ThreadExecProc(LPVOID pParam)
{
	CThread *pThread = (CThread*)pParam;
	int nReturnValue = 0;

	if (!pThread->m_bTerminated)
	{
		struct CAutoFinalizer
		{
			CThread *m_pThread;
			CAutoFinalizer(CThread *pThread) { m_pThread = pThread; }
			~CAutoFinalizer()
			{
				m_pThread->m_bFinished = true;
				if (m_pThread->GetFreeOnTerminate())
					delete m_pThread;
				else
					m_pThread->m_nThreadId = 0;
			}
		} AutoFinalizer(pThread);

		CATCH_ALL_EXCEPTION( pThread->Execute(); );
		CATCH_ALL_EXCEPTION( pThread->AfterExecute(); );