forked from spanio/C_StateMachine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLockGuard.cpp
46 lines (40 loc) · 1.19 KB
/
LockGuard.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "LockGuard.h"
#include "Fault.h"
#include <mutex>
// A lock is a mutex
#define LOCK std::mutex
//------------------------------------------------------------------------------
// LK_Create
//------------------------------------------------------------------------------
LOCK_HANDLE LK_Create(void)
{
LOCK* lock = new LOCK;
return lock;
}
//------------------------------------------------------------------------------
// LK_Destroy
//------------------------------------------------------------------------------
void LK_Destroy(LOCK_HANDLE hLock)
{
ASSERT_TRUE(hLock);
LOCK* lock = (LOCK*)(hLock);
delete lock;
}
//------------------------------------------------------------------------------
// LK_Lock
//------------------------------------------------------------------------------
void LK_Lock(LOCK_HANDLE hLock)
{
ASSERT_TRUE(hLock);
LOCK* lock = (LOCK*)(hLock);
lock->lock();
}
//------------------------------------------------------------------------------
// LK_Unlock
//------------------------------------------------------------------------------
void LK_Unlock(LOCK_HANDLE hLock)
{
ASSERT_TRUE(hLock);
LOCK* lock = (LOCK*)(hLock);
lock->unlock();
}