Initial
This commit is contained in:
40
thread/EVENT.CPP
Normal file
40
thread/EVENT.CPP
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <thread/event.hpp>
|
||||
#include <thread/postfix.hpp>
|
||||
|
||||
Event::Event(BOOL manualReset)
|
||||
: mhEvent(0), mEventName("Event")
|
||||
{
|
||||
PostFix postFix;
|
||||
postFix.postFix(mEventName);
|
||||
mhEvent=::CreateEvent((LPSECURITY_ATTRIBUTES)0,manualReset,FALSE,mEventName);
|
||||
}
|
||||
|
||||
Event::Event(const String &eventName,BOOL postFixup,BOOL manualReset)
|
||||
: mhEvent(0)
|
||||
{
|
||||
PostFix postFix;
|
||||
if(eventName.isNull())return;
|
||||
mEventName=eventName;
|
||||
if(postFixup)postFix.postFix(mEventName);
|
||||
mhEvent=::CreateEvent((LPSECURITY_ATTRIBUTES)0,manualReset,FALSE,mEventName);
|
||||
}
|
||||
|
||||
WORD Event::waitEvent(DWORD timeOut,WORD alertable)const
|
||||
{
|
||||
DWORD waitResult;
|
||||
|
||||
if(!isOkay())return FALSE;
|
||||
waitResult=::WaitForSingleObjectEx(mhEvent,timeOut,alertable);
|
||||
if(WAIT_ABANDONED==waitResult)return FALSE;
|
||||
else if(WAIT_TIMEOUT==waitResult)return FALSE;
|
||||
else if(WAIT_OBJECT_0==waitResult)return TRUE;
|
||||
else return TRUE;
|
||||
}
|
||||
|
||||
WORD Event::closeEvent(void)
|
||||
{
|
||||
if(!isOkay())return FALSE;
|
||||
::CloseHandle(mhEvent);
|
||||
mhEvent=0;
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user