Created
May 14, 2020 14:27
-
-
Save BruJu/838ba28fa522b553424b17e8683fb012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <bool try_lock_return> | |
class DebugMutex { | |
#ifdef DEBUG | |
private: std::mutex _mutex; | |
public: | |
void lock() { _mutex.lock(); } | |
void unlock() { _mutex.unlock(); } | |
bool try_lock() { return _mutex.try_lock(); } | |
#else | |
public: | |
void lock() {} | |
void unlock() {} | |
bool try_lock() { return try_lock_return; } | |
#endif | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment