Fix #include guards.
[oota-llvm.git] / include / llvm / System / RWMutex.h
1 //===- RWMutex.h - Reader/Writer Mutual Exclusion Lock ----------*- C++ -*-===//
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 declares the llvm::sys::RWMutex class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SYSTEM_RWMUTEX_H
15 #define LLVM_SYSTEM_RWMUTEX_H
16
17 namespace llvm
18 {
19   namespace sys
20   {
21     /// @brief Platform agnostic Mutex class.
22     class RWMutex
23     {
24     /// @name Constructors
25     /// @{
26     public:
27
28       /// Initializes the lock but doesn't acquire it.
29       /// @brief Default Constructor.
30       explicit RWMutex();
31
32       /// Releases and removes the lock
33       /// @brief Destructor
34       ~RWMutex();
35
36     /// @}
37     /// @name Methods
38     /// @{
39     public:
40
41       /// Attempts to unconditionally acquire the lock in reader mode. If the
42       /// lock is held by a writer, this method will wait until it can acquire
43       /// the lock. 
44       /// @returns false if any kind of error occurs, true otherwise.
45       /// @brief Unconditionally acquire the lock in reader mode.
46       bool reader_acquire();
47
48       /// Attempts to release the lock in reader mode.
49       /// @returns false if any kind of error occurs, true otherwise.
50       /// @brief Unconditionally release the lock in reader mode.
51       bool reader_release();
52
53       /// Attempts to unconditionally acquire the lock in reader mode. If the
54       /// lock is held by any readers, this method will wait until it can
55       /// acquire the lock. 
56       /// @returns false if any kind of error occurs, true otherwise.
57       /// @brief Unconditionally acquire the lock in writer mode.
58       bool writer_acquire();
59
60       /// Attempts to release the lock in writer mode.
61       /// @returns false if any kind of error occurs, true otherwise.
62       /// @brief Unconditionally release the lock in write mode.
63       bool writer_release();
64
65     //@}
66     /// @name Platform Dependent Data
67     /// @{
68     private:
69 #ifdef ENABLE_THREADS
70       void* data_; ///< We don't know what the data will be
71 #endif
72
73     /// @}
74     /// @name Do Not Implement
75     /// @{
76     private:
77       RWMutex(const RWMutex & original);
78       void operator=(const RWMutex &);
79     /// @}
80     };
81   }
82 }
83
84 #endif