]> git.tdb.fi Git - libs/core.git/blob - source/core/windows/mutex.cpp
Add a refcount function to RefPtr
[libs/core.git] / source / core / windows / mutex.cpp
1 #include <windows.h>
2 #include "mutex.h"
3 #include "mutex_private.h"
4
5 namespace Msp {
6
7 Mutex::Mutex():
8         priv(new Private)
9 {
10         InitializeCriticalSection(&priv->mutex);
11 }
12
13 Mutex::~Mutex()
14 {
15         DeleteCriticalSection(&priv->mutex);
16         delete priv;
17 }
18
19 void Mutex::lock()
20 {
21         EnterCriticalSection(&priv->mutex);
22 }
23
24 bool Mutex::trylock()
25 {
26         return TryEnterCriticalSection(&priv->mutex);
27 }
28
29 void Mutex::unlock()
30 {
31         LeaveCriticalSection(&priv->mutex);
32 }
33
34 } // namespace Msp