X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fwindows%2Fmutex.cpp;fp=source%2Fcore%2Fwindows%2Fmutex.cpp;h=e51fda407b8a9beead0b3ce35040697ed7e54bcf;hb=609c9a508cfdc7b42c46c4f21d17639204165a00;hp=0000000000000000000000000000000000000000;hpb=b4806214e905752617691f851717033fd3f266c2;p=libs%2Fcore.git diff --git a/source/core/windows/mutex.cpp b/source/core/windows/mutex.cpp new file mode 100644 index 0000000..e51fda4 --- /dev/null +++ b/source/core/windows/mutex.cpp @@ -0,0 +1,34 @@ +#include +#include "mutex.h" +#include "mutex_private.h" + +namespace Msp { + +Mutex::Mutex(): + priv(new Private) +{ + InitializeCriticalSection(&priv->mutex); +} + +Mutex::~Mutex() +{ + DeleteCriticalSection(&priv->mutex); + delete priv; +} + +void Mutex::lock() +{ + EnterCriticalSection(&priv->mutex); +} + +bool Mutex::trylock() +{ + return TryEnterCriticalSection(&priv->mutex); +} + +void Mutex::unlock() +{ + LeaveCriticalSection(&priv->mutex); +} + +} // namespace Msp