Пример #1
0
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;
}
DWORD WINAPI CThread::ThreadProc(LPVOID lpParameter)
{
	   CThread *pThread = (CThread *)lpParameter;
	   if(pThread)
	      return pThread->Execute();
	   else
		  return (DWORD)-1;
}
void *CThread::ThreadProc(void *obj)
{
      CThread *pThread = static_cast<CThread*>(obj);

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

      return NULL;
}
Пример #4
0
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
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
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
//-----------------------------------------------------------------------------
// 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(); );