Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created May 14, 2020 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/838ba28fa522b553424b17e8683fb012 to your computer and use it in GitHub Desktop.
Save BruJu/838ba28fa522b553424b17e8683fb012 to your computer and use it in GitHub Desktop.
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