From 3128281e50d30d12a053bc06018df4efcc8e988e Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 10 Jun 2021 11:12:25 +0800 Subject: ... --- operating-system-experiment/Mutex.h | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 operating-system-experiment/Mutex.h (limited to 'operating-system-experiment/Mutex.h') diff --git a/operating-system-experiment/Mutex.h b/operating-system-experiment/Mutex.h new file mode 100644 index 0000000..163d9ca --- /dev/null +++ b/operating-system-experiment/Mutex.h @@ -0,0 +1,44 @@ +#ifndef HEADER_MUTEX_H +#define HEADER_MUTEX_H + +#include "Base.h" + +#include + +#ifdef CRU_WINDOWS +#include +#else +#include +#endif + +namespace cru { +class CRU_API Mutex { +public: + Mutex(); + + Mutex(const Mutex &other) = delete; + Mutex &operator=(const Mutex &other) = delete; + + Mutex(Mutex &&other); + Mutex &operator=(Mutex &&other); + + ~Mutex(); + +public: + void Lock(); + bool TryLock(); + + void Unlock(); + +private: + void Destroy(); + +private: +#ifdef CRU_WINDOWS +#else + std::unique_ptr mutex_; +#endif +}; +} // namespace cru + +#endif \ No newline at end of file -- cgit v1.2.3