From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Threads/Posix/PlatformMutex.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Runtime/Threads/Posix/PlatformMutex.h (limited to 'Runtime/Threads/Posix/PlatformMutex.h') diff --git a/Runtime/Threads/Posix/PlatformMutex.h b/Runtime/Threads/Posix/PlatformMutex.h new file mode 100644 index 0000000..0071094 --- /dev/null +++ b/Runtime/Threads/Posix/PlatformMutex.h @@ -0,0 +1,29 @@ +#ifndef __PLATFORMMUTEX_H +#define __PLATFORMMUTEX_H + +#if SUPPORT_THREADS + +#include +#include "Runtime/Utilities/NonCopyable.h" + +/** + * A platform/api specific mutex class. Always recursive (a single thread can lock multiple times). + */ +class PlatformMutex : public NonCopyable +{ + friend class Mutex; +protected: + PlatformMutex(); + ~PlatformMutex(); + + void Lock(); + void Unlock(); + bool TryLock(); + +private: + + pthread_mutex_t mutex; +}; + +#endif // SUPPORT_THREADS +#endif // __PLATFORMMUTEX_H -- cgit v1.1-26-g67d0