Files
libsst/ZUtil/ZMutex.cpp
2026-04-03 00:22:39 -05:00

43 lines
693 B
C++

#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();
}