LLVM  8.0.1
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 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool reader_release()
Attempts to release the lock in reader mode.
Definition: RWMutex.cpp:89
bool writer_acquire()
Attempts to unconditionally acquire the lock in reader mode.
Definition: RWMutex.cpp:99
bool reader_acquire()
Attempts to unconditionally acquire the lock in reader mode.
Definition: RWMutex.cpp:79
RWMutexImpl()
Initializes the lock but doesn&#39;t acquire it.
Definition: RWMutex.cpp:49
bool writer_release()
Attempts to release the lock in writer mode.
Definition: RWMutex.cpp:109
~RWMutexImpl()
Releases and removes the lock Destructor.
Definition: RWMutex.cpp:70