OpenBarnyard
 
Loading...
Searching...
No Matches
TSemaphore_Win.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
2#include "TSemaphore_Win.h"
3
4#include <windows.h>
5
6//-----------------------------------------------------------------------------
7// Enables memory debugging.
8// Note: Should be the last include!
9//-----------------------------------------------------------------------------
10#include "Core/TMemoryDebugOn.h"
11
13
18
20{
21 return WaitForSingleObject( m_hSemaHnd, 0 ) == WAIT_OBJECT_0;
22}
23
25{
26 return WaitForSingleObject( m_hSemaHnd, INFINITE ) == WAIT_OBJECT_0;
27}
28
29// $Barnyard: FUNCTION 006bb640
31{
32 TASSERT( m_hSemaHnd != NULL, "Handle is NULL" );
33 return ReleaseSemaphore( m_hSemaHnd, 1, NULL );
34}
35
37{
38 return TFALSE;
39}
40
41TBOOL TSemaphore::Create( TINT a_iInitCount, TINT a_iMaxCount )
42{
43 TASSERT( a_iInitCount >= 0, "Init count should be greater than zero" );
44 TASSERT( a_iMaxCount >= a_iInitCount, "Init count cannot be less than max count" );
45
46 m_hSemaHnd = CreateSemaphoreA( NULL, a_iInitCount, a_iMaxCount, NULL );
47 TASSERT( m_hSemaHnd != NULL, "Unable to create semaphore" );
48
49 return TTRUE;
50}
51
#define TASSERT(X,...)
Definition Defines.h:138
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TBOOL Create(TINT a_iInitCount, TINT a_iMaxCount)