LLVM  6.0.0svn
RWMutex.inc
Go to the documentation of this file.
1 //= llvm/Support/Unix/RWMutex.inc - Unix Reader/Writer Mutual Exclusion Lock =//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Unix specific (non-pthread) RWMutex class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 //===----------------------------------------------------------------------===//
15 //=== WARNING: Implementation here must contain only generic UNIX code that
16 //=== is guaranteed to work on *all* UNIX variants.
17 //===----------------------------------------------------------------------===//
18 
19 #include "llvm/Support/Mutex.h"
20 
21 namespace llvm {
22 
23 using namespace sys;
24 
25 // This naive implementation treats readers the same as writers. This
26 // will therefore deadlock if a thread tries to acquire a read lock
27 // multiple times.
28 
29 RWMutexImpl::RWMutexImpl() : data_(new MutexImpl(false)) { }
30 
32  delete static_cast<MutexImpl *>(data_);
33 }
34 
36  return static_cast<MutexImpl *>(data_)->acquire();
37 }
38 
40  return static_cast<MutexImpl *>(data_)->release();
41 }
42 
44  return static_cast<MutexImpl *>(data_)->acquire();
45 }
46 
48  return static_cast<MutexImpl *>(data_)->release();
49 }
50 
51 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool reader_release()
Attempts to release the lock in reader mode.
Definition: RWMutex.cpp:88
bool writer_acquire()
Attempts to unconditionally acquire the lock in reader mode.
Definition: RWMutex.cpp:98
bool reader_acquire()
Attempts to unconditionally acquire the lock in reader mode.
Definition: RWMutex.cpp:78
RWMutexImpl()
Initializes the lock but doesn&#39;t acquire it.
Definition: RWMutex.cpp:48
bool writer_release()
Attempts to release the lock in writer mode.
Definition: RWMutex.cpp:108
~RWMutexImpl()
Releases and removes the lock.
Definition: RWMutex.cpp:69