00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "stdafx.h"
00037 #include "Win32Event.h"
00038
00039 #ifdef _MEMORY_DEBUG
00040 #define new DEBUG_NEW
00041 #define malloc DEBUG_MALLOC
00042 static char THIS_FILE[] = __FILE__;
00043 #endif
00044
00045 KOMODIA_NAMESPACE_START
00046
00047 CWin32Event::CWin32Event(BOOL bInitialState,
00048 BOOL bManualReset,
00049 const char* pEventName) : CGenericEvent(bInitialState,
00050 bManualReset,
00051 pEventName),
00052 m_hEvent(NULL)
00053 {
00054
00055 m_hEvent=CreateEvent(NULL,
00056 bManualReset,
00057 bInitialState,
00058 pEventName);
00059
00060
00061 if (pEventName &&
00062 GetLastError()!=ERROR_ALREADY_EXISTS)
00063 SetFirst();
00064 }
00065
00066 CWin32Event::~CWin32Event()
00067 {
00068 if (!m_hEvent)
00069 CloseHandle(m_hEvent);
00070 }
00071
00072 void CWin32Event::Set()
00073 {
00074 if (m_hEvent)
00075 SetEvent(m_hEvent);
00076 }
00077
00078 BOOL CWin32Event::Wait(unsigned long ulMSTimeout)
00079 {
00080 DWORD dwWaitResult;
00081
00082
00083 dwWaitResult=WaitForSingleObject(m_hEvent,ulMSTimeout);
00084
00085
00086 return dwWaitResult==WAIT_TIMEOUT;
00087 }
00088
00089 HANDLE CWin32Event::GetHandle()const
00090 {
00091 return m_hEvent;
00092 }
00093
00094 void CWin32Event::Reset()
00095 {
00096 if (m_hEvent)
00097 ResetEvent(m_hEvent);
00098 }
00099
00100 void CWin32Event::Pulse()
00101 {
00102 if (m_hEvent)
00103 PulseEvent(m_hEvent);
00104 }
00105
00106 void CWin32Event::ReleaseObject()
00107 {
00108 Reset();
00109 }
00110
00111 KOMODIA_NAMESPACE_END