1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/*
$Id: event_trigger_win32.cpp,v 1.8 2001/12/17 20:11:40 mbn Exp $
------------------------------------------------------------------------
ClanLib, the platform independent game SDK.
This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
version 2. See COPYING for details.
For a total list of contributers see CREDITS.
------------------------------------------------------------------------
*/
#include "Core/precomp.h"
#include "event_trigger_win32.h"
/////////////////////////////////////////////////////////////////////////////
// CL_EventTrigger_Win32 construction:
CL_EventTrigger_Win32::CL_EventTrigger_Win32()
:
wait_handle(NULL)
{
wait_handle = CreateEvent(NULL, TRUE, FALSE, NULL);
}
CL_EventTrigger_Win32::~CL_EventTrigger_Win32()
{
CloseHandle(wait_handle);
}
/////////////////////////////////////////////////////////////////////////////
// CL_EventTrigger_Win32 attributes:
bool CL_EventTrigger_Win32::get_flag() const
{
return WaitForSingleObject(wait_handle, 0) != WAIT_TIMEOUT;
}
/////////////////////////////////////////////////////////////////////////////
// CL_EventTrigger_Win32 operations:
void CL_EventTrigger_Win32::reset() const
{
ResetEvent(wait_handle);
}
void CL_EventTrigger_Win32::set_flag()
{
SetEvent(wait_handle);
}
bool CL_EventTrigger_Win32::wait(int timeout) const
{
DWORD result = WaitForSingleObject(
wait_handle,
(timeout == -1) ? INFINITE : timeout);
return (result != WAIT_TIMEOUT);
}
/////////////////////////////////////////////////////////////////////////////
// CL_EventTrigger_Win32 implementation:
|