1 #pragma once
2 #include "stdafx.h"
3 #include <thread>
4 
5 class SimpleLock;
6 
7 class LockHandler
8 {
9 private:
10 	SimpleLock *_lock;
11 public:
12 	LockHandler(SimpleLock *lock);
13 	~LockHandler();
14 };
15 
16 class SimpleLock
17 {
18 private:
19 	thread_local static std::thread::id _threadID;
20 
21 	std::thread::id _holderThreadID;
22 	uint32_t _lockCount;
23 	atomic_flag _lock;
24 
25 public:
26 	SimpleLock();
27 	~SimpleLock();
28 
29 	LockHandler AcquireSafe();
30 
31 	void Acquire();
32 	bool IsFree();
33 	void WaitForRelease();
34 	void Release();
35 };
36 
37