diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:08:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:08:18 +0000 |
commit | 5ca98fd98791947eba83a1ed3f2c8191ef7afa6c (patch) | |
tree | f5944309621cee4fe0976be6f9ac619b7ebfc4c2 /lib/Support/Unix/RWMutex.inc | |
parent | 68bcb7db193e4bc81430063148253d30a791023e (diff) |
Diffstat (limited to 'lib/Support/Unix/RWMutex.inc')
-rw-r--r-- | lib/Support/Unix/RWMutex.inc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Support/Unix/RWMutex.inc b/lib/Support/Unix/RWMutex.inc index 40e87ff13111..edcbd52f5f37 100644 --- a/lib/Support/Unix/RWMutex.inc +++ b/lib/Support/Unix/RWMutex.inc @@ -16,28 +16,36 @@ //=== is guaranteed to work on *all* UNIX variants. //===----------------------------------------------------------------------===// +#include "llvm/Support/Mutex.h" + namespace llvm { using namespace sys; -RWMutexImpl::RWMutexImpl() { } +// This naive implementation treats readers the same as writers. This +// will therefore deadlock if a thread tries to acquire a read lock +// multiple times. + +RWMutexImpl::RWMutexImpl() : data_(new Mutex(false)) { } -RWMutexImpl::~RWMutexImpl() { } +RWMutexImpl::~RWMutexImpl() { + delete static_cast<Mutex *>(data_); +} bool RWMutexImpl::reader_acquire() { - return true; + return static_cast<Mutex *>(data_)->acquire(); } bool RWMutexImpl::reader_release() { - return true; + return static_cast<Mutex *>(data_)->release(); } bool RWMutexImpl::writer_acquire() { - return true; + return static_cast<Mutex *>(data_)->acquire(); } bool RWMutexImpl::writer_release() { - return true; + return static_cast<Mutex *>(data_)->release(); } } |