mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 22:31:46 +00:00
[c-host] windows: added event support
This commit is contained in:
parent
be736c48e9
commit
f572a72c2a
1 changed files with 39 additions and 0 deletions
|
@ -298,4 +298,43 @@ bool os_joinThread(osThreadHandle * handle, int * resultCode)
|
||||||
|
|
||||||
DEBUG_WINERROR("Unknown failure waiting for thread", GetLastError());
|
DEBUG_WINERROR("Unknown failure waiting for thread", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
osEventHandle * os_createEvent()
|
||||||
|
{
|
||||||
|
HANDLE event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
return (osEventHandle*)event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void os_freeEvent(osEventHandle * handle)
|
||||||
|
{
|
||||||
|
CloseHandle((HANDLE)handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool os_waitEvent(osEventHandle * handle)
|
||||||
|
{
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
switch(WaitForSingleObject((HANDLE)handle, INFINITE))
|
||||||
|
{
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case WAIT_ABANDONED:
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case WAIT_FAILED:
|
||||||
|
DEBUG_WINERROR("Wait for event failed", GetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_ERROR("Unknown wait event return code");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool os_signalEvent(osEventHandle * handle)
|
||||||
|
{
|
||||||
|
return SetEvent((HANDLE)handle);
|
||||||
}
|
}
|
Loading…
Reference in a new issue