feat(util/shared_mutex): skip shared_mutex implementation if LEAN_MULTI_THREAD is not defined
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
8f2fe273ea
commit
533ed51f51
2 changed files with 20 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "util/shared_mutex.h"
|
||||
|
||||
namespace lean {
|
||||
#if defined(LEAN_MULTI_THREAD)
|
||||
shared_mutex::shared_mutex():m_rw_counter(0), m_state(0) {}
|
||||
shared_mutex::~shared_mutex() {
|
||||
lock_guard<mutex> lock(m_mutex);
|
||||
|
@ -117,4 +118,5 @@ void shared_mutex::unlock_shared() {
|
|||
m_gate1.notify_one();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "util/thread.h"
|
||||
|
||||
namespace lean {
|
||||
#if defined(LEAN_MULTI_THREAD)
|
||||
class shared_mutex {
|
||||
mutex m_mutex;
|
||||
thread::id m_rw_owner;
|
||||
|
@ -42,6 +43,23 @@ public:
|
|||
bool try_lock_shared();
|
||||
void unlock_shared();
|
||||
};
|
||||
#else
|
||||
class shared_mutex {
|
||||
public:
|
||||
shared_mutex() {}
|
||||
shared_mutex(shared_mutex const &) = delete;
|
||||
shared_mutex(shared_mutex &&) = delete;
|
||||
shared_mutex& operator=(shared_mutex const &) = delete;
|
||||
shared_mutex&& operator=(shared_mutex &&) = delete;
|
||||
void lock() {}
|
||||
bool try_lock() { return true; }
|
||||
void unlock() {}
|
||||
|
||||
void lock_shared() {}
|
||||
bool try_lock_shared() { return true; }
|
||||
void unlock_shared() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
class shared_lock {
|
||||
shared_mutex & m_mutex;
|
||||
|
|
Loading…
Reference in a new issue