OpenBarnyard
 
Loading...
Searching...
No Matches
TSemaphore Class Reference

#include <TSemaphore_Win.h>

Public Member Functions

 TSemaphore ()=default
 
 ~TSemaphore ()
 
TBOOL Create (TINT a_iInitCount, TINT a_iMaxCount)
 
TBOOL Destroy ()
 
TBOOL Signal ()
 
TBOOL Wait ()
 
TBOOL Poll ()
 

Detailed Description

Definition at line 5 of file TSemaphore_Win.h.

Constructor & Destructor Documentation

◆ TSemaphore()

TSemaphore::TSemaphore ( )
default

◆ ~TSemaphore()

TSemaphore::~TSemaphore ( )

Definition at line 14 of file TSemaphore_Win.cpp.

15{
16 Destroy();
17}

Member Function Documentation

◆ Create()

TBOOL TSemaphore::Create ( TINT a_iInitCount,
TINT a_iMaxCount )

Definition at line 41 of file TSemaphore_Win.cpp.

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}
#define TASSERT(X,...)
Definition Defines.h:138
#define TTRUE
Definition Typedefs.h:25

◆ Destroy()

TBOOL TSemaphore::Destroy ( )

Definition at line 36 of file TSemaphore_Win.cpp.

37{
38 return TFALSE;
39}
#define TFALSE
Definition Typedefs.h:24

◆ Poll()

TBOOL TSemaphore::Poll ( )

Definition at line 19 of file TSemaphore_Win.cpp.

20{
21 return WaitForSingleObject( m_hSemaHnd, 0 ) == WAIT_OBJECT_0;
22}

◆ Signal()

TBOOL TSemaphore::Signal ( )

Definition at line 30 of file TSemaphore_Win.cpp.

31{
32 TASSERT( m_hSemaHnd != NULL, "Handle is NULL" );
33 return ReleaseSemaphore( m_hSemaHnd, 1, NULL );
34}

◆ Wait()

TBOOL TSemaphore::Wait ( )

Definition at line 24 of file TSemaphore_Win.cpp.

25{
26 return WaitForSingleObject( m_hSemaHnd, INFINITE ) == WAIT_OBJECT_0;
27}

The documentation for this class was generated from the following files: