Initial commit
This commit is contained in:
42
ZUtil/ZMutex.cpp
Normal file
42
ZUtil/ZMutex.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <ZUtil/ZMutex.hpp>
|
||||
#include <ZUtil/ZAssert.hpp>
|
||||
|
||||
//////////////////////////
|
||||
/* ZLock Implementation */
|
||||
//////////////////////////
|
||||
|
||||
ZMutex::ZMutex()
|
||||
: Mutex(SST_Concurrency_CreateMutex())
|
||||
{
|
||||
ZASSERT_RUNTIME(Mutex != NULL, "ZMutex failed to allocate mutex from libsst-concurrency!");
|
||||
}
|
||||
|
||||
ZMutex::~ZMutex()
|
||||
{
|
||||
SST_Concurrency_DestroyMutex(Mutex);
|
||||
}
|
||||
|
||||
void ZMutex::Acquire()
|
||||
{
|
||||
SST_Concurrency_LockMutex(Mutex);
|
||||
}
|
||||
|
||||
void ZMutex::Release()
|
||||
{
|
||||
SST_Concurrency_UnlockMutex(Mutex);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
/* ZScopedLock Implementation */
|
||||
////////////////////////////////
|
||||
|
||||
ZLock::ZLock( ZMutex& _mutex )
|
||||
: Mutex(_mutex)
|
||||
{
|
||||
Mutex.Acquire();
|
||||
}
|
||||
|
||||
ZLock::~ZLock()
|
||||
{
|
||||
Mutex.Release();
|
||||
}
|
||||
Reference in New Issue
Block a user