Initial commit
This commit is contained in:
35
ZUtil/ZSemaphore.cpp
Normal file
35
ZUtil/ZSemaphore.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <ZUtil/ZSemaphore.hpp>
|
||||
#include <ZUtil/ZAssert.hpp>
|
||||
#include <SST/SST_Concurrency.h> //For SST_WAIT_INFINITE
|
||||
|
||||
ZSemaphore::ZSemaphore(int _initialCount)
|
||||
: Semaphore(SST_Concurrency_CreateSemaphore(_initialCount))
|
||||
{
|
||||
ZASSERT_RUNTIME(Semaphore != NULL, "ZSemaphore failed to allocate semaphore from libsst-concurrency!");
|
||||
}
|
||||
|
||||
ZSemaphore::~ZSemaphore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ZSemaphore::Post()
|
||||
{
|
||||
SST_Concurrency_PostSemaphore(Semaphore, 1);
|
||||
}
|
||||
|
||||
void ZSemaphore::Post( uint32_t _count )
|
||||
{
|
||||
SST_Concurrency_PostSemaphore(Semaphore, _count);
|
||||
}
|
||||
|
||||
bool ZSemaphore::Wait()
|
||||
{
|
||||
return SST_Concurrency_WaitSemaphore(Semaphore, SST_WAIT_INFINITE) != 0;
|
||||
}
|
||||
|
||||
bool ZSemaphore::Wait( uint32_t _ms )
|
||||
{
|
||||
return SST_Concurrency_WaitSemaphore(Semaphore, _ms) != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user