Isle
Loading...
Searching...
No Matches
mxsemaphore.cpp
Go to the documentation of this file.
1
2#include "mxsemaphore.h"
3
4#include "decomp.h"
5
7
8// FUNCTION: LEGO1 0x100c87d0
10{
11 m_hSemaphore = NULL;
12}
13
14// FUNCTION: LEGO1 0x100c8800
15MxResult MxSemaphore::Init(MxU32 p_initialCount, MxU32 p_maxCount)
16{
17 MxResult result = FAILURE;
18
19 if ((m_hSemaphore = CreateSemaphoreA(NULL, p_initialCount, p_maxCount, NULL))) {
20 result = SUCCESS;
21 }
22
23 return result;
24}
25
26// FUNCTION: LEGO1 0x100c8830
27void MxSemaphore::Wait(MxU32 p_timeoutMS)
28{
29 WaitForSingleObject(m_hSemaphore, p_timeoutMS);
30}
31
32// FUNCTION: LEGO1 0x100c8850
33void MxSemaphore::Release(MxU32 p_releaseCount)
34{
35 ReleaseSemaphore(m_hSemaphore, p_releaseCount, NULL);
36}
Implements a lightweight wrapper for Windows semaphores, allowing safe synchronization between thread...
Definition: mxsemaphore.h:15
virtual MxResult Init(MxU32 p_initialCount, MxU32 p_maxCount)
Initializes the semaphore with both initial and maximum counts.
Definition: mxsemaphore.cpp:15
void Release(MxU32 p_releaseCount)
Increases the semaphore count, unblocking waiting threads if any.
Definition: mxsemaphore.cpp:33
void Wait(MxU32 p_timeoutMS)
Waits on the semaphore for the specified timeout (in milliseconds).
Definition: mxsemaphore.cpp:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
MxLong MxResult
[AI]
Definition: mxtypes.h:106
unsigned int MxU32
[AI]
Definition: mxtypes.h:32