?? retrievalthread.cpp
字號:
//---------------------------------------------------------------------------
//
// RetrievalThread.cpp
//
// SUBSYSTEM:
// Monitoring process creation and termination
//
// MODULE:
// Provides an interface for handling queued items
//
// DESCRIPTION:
//
// AUTHOR: Ivo Ivanov
//
//---------------------------------------------------------------------------
#include "stdafx.h"
#include "RetrievalThread.h"
#include "QueueContainer.h"
#include ".\retrievalthread.h"
//---------------------------------------------------------------------------
//
// class CQueueReadThread
//
//---------------------------------------------------------------------------
CQueueReadThread::CQueueReadThread( TCHAR* pszThreadGuid, CQueueContainer* pQueue )
: CCustomThread(pszThreadGuid)
, m_pQueueManager(pQueue)
{
assert( NULL != m_pQueueManager );
// Create the "remove" event
//
m_hEventAvailable = ::CreateEvent(NULL, FALSE, FALSE, NULL);
assert(NULL != m_hEventAvailable);
}
CQueueReadThread::~CQueueReadThread()
{
if (NULL != m_hEventAvailable)
{
::CloseHandle(m_hEventAvailable);
}
}
// A user supplied implementation of the thread function.
// Override Run() and insert the code that should be executed when
// the thread runs.
void CQueueReadThread::Run()
{
HANDLE handles[2] =
{
m_hShutdownEvent,
m_hEventAvailable
};
while (TRUE)
{
DWORD dwResult = ::WaitForMultipleObjects(
sizeof(handles)/sizeof(handles[0]), // number of handles in array
&handles[0], // object-handle array
FALSE, // wait option
INFINITE // time-out interval
);
// the system shuts down
if (handles[dwResult - WAIT_OBJECT_0] == m_hShutdownEvent)
{
break;
}
else // An element just became available in the queue
{
m_pQueueManager->DoOnProcessCreatedTerminated();
}
} // while
}
// A method for accessing handle to an internal event handle
HANDLE CQueueReadThread::Get_EventAvailable() const
{
return m_hEventAvailable;
}
void CQueueReadThread::EventNotify(bool bSetEvent)
{
if( bSetEvent )
{
::SetEvent(m_hEventAvailable);
}
else
{
::ResetEvent(m_hEventAvailable);
}
}
//----------------------------End of the file -------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -