Isle
|
Implements a lightweight wrapper for Windows semaphores, allowing safe synchronization between threads. More...
#include <mxsemaphore.h>
Public Member Functions | |
MxSemaphore () | |
Constructs the MxSemaphore object; initializes internal handle to NULL. More... | |
~MxSemaphore () | |
Destructor, closes the semaphore handle if open. More... | |
virtual MxResult | Init (MxU32 p_initialCount, MxU32 p_maxCount) |
Initializes the semaphore with both initial and maximum counts. More... | |
void | Wait (MxU32 p_timeoutMS) |
Waits on the semaphore for the specified timeout (in milliseconds). More... | |
void | Release (MxU32 p_releaseCount) |
Increases the semaphore count, unblocking waiting threads if any. More... | |
Implements a lightweight wrapper for Windows semaphores, allowing safe synchronization between threads.
[AI]
[AI] MxSemaphore provides methods for initializing, waiting on, and releasing a Windows semaphore object, supporting cross-thread signaling and limiting concurrent execution. Used as a utility for resource management, thread pool gates, and similar concurrency control. [AI]
Definition at line 15 of file mxsemaphore.h.
MxSemaphore::MxSemaphore | ( | ) |
Constructs the MxSemaphore object; initializes internal handle to NULL.
[AI]
Definition at line 9 of file mxsemaphore.cpp.
|
inline |
Destructor, closes the semaphore handle if open.
[AI]
[AI] This cleans up OS resources, preventing handle leaks.
Definition at line 26 of file mxsemaphore.h.
Initializes the semaphore with both initial and maximum counts.
[AI]
p_initialCount | The initial count for the semaphore (i.e., how many Wait() calls will succeed before blocking). [AI] |
p_maxCount | The maximum value the semaphore count can reach. [AI] |
[AI] Allocates the Windows semaphore resource and prepares it for use. Subsequent Wait and Release calls must only occur after successful initialization. [AI]
Definition at line 15 of file mxsemaphore.cpp.
void MxSemaphore::Release | ( | MxU32 | p_releaseCount | ) |
Increases the semaphore count, unblocking waiting threads if any.
[AI]
p_releaseCount | Increment amount for the semaphore's internal counter; typically 1 for single-release. [AI] |
[AI] Allows up to p_releaseCount threads blocked in Wait to proceed. [AI]
Definition at line 33 of file mxsemaphore.cpp.
void MxSemaphore::Wait | ( | MxU32 | p_timeoutMS | ) |
Waits on the semaphore for the specified timeout (in milliseconds).
[AI]
p_timeoutMS | Timeout in milliseconds to wait before the operation is considered unsuccessful. [AI] |
[AI] Decrements the semaphore counter if it is positive, otherwise blocks for up to the specified timeout unless Release is called from another thread. [AI]
Definition at line 27 of file mxsemaphore.cpp.