Enderal SE https://mod.pub/enderal-se/38-enderal-se
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
564 B
35 lines
564 B
3 years ago
|
#include "IMutex.h"
|
||
|
|
||
|
IMutex::IMutex()
|
||
|
{
|
||
|
theMutex = CreateMutex(NULL, true, NULL);
|
||
|
}
|
||
|
|
||
|
IMutex::~IMutex()
|
||
|
{
|
||
|
CloseHandle(theMutex);
|
||
|
}
|
||
|
|
||
|
bool IMutex::Wait(UInt32 timeout)
|
||
|
{
|
||
|
switch(WaitForSingleObject(theMutex, timeout))
|
||
|
{
|
||
|
case WAIT_ABANDONED:
|
||
|
HALT("IMutex::Wait: got abandoned mutex");
|
||
|
return false;
|
||
|
|
||
|
case WAIT_OBJECT_0:
|
||
|
return true;
|
||
|
|
||
|
default:
|
||
|
case WAIT_TIMEOUT:
|
||
|
gLog.FormattedMessage("IMutex::Wait: timeout");
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void IMutex::Release(void)
|
||
|
{
|
||
|
ASSERT_STR(ReleaseMutex(theMutex), "IMutex::Release: failed to release mutex");
|
||
|
}
|