activemq-cpp-3.8.2
ReentrantReadWriteLock.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_
19 #define _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_
20 
21 #include <decaf/util/Config.h>
22 
23 #include <decaf/lang/Thread.h>
24 #include <decaf/util/Collection.h>
26 
27 namespace decaf {
28 namespace util {
29 namespace concurrent {
30 namespace locks {
31 
32  class ReentrantReadWriteLockImpl;
33 
39  private:
40 
41  ReentrantReadWriteLockImpl* impl;
42 
43  private:
44 
47 
48  public:
49 
54 
61  ReentrantReadWriteLock(bool fair);
62 
63  virtual ~ReentrantReadWriteLock();
64 
65  public:
66 
70  virtual decaf::util::concurrent::locks::Lock& readLock();
71 
75  virtual decaf::util::concurrent::locks::Lock& writeLock();
76 
82  bool isFair() const;
83 
90  int getReadLockCount() const;
91 
98  bool isWriteLocked() const;
99 
105  bool isWriteLockedByCurrentThread() const;
106 
115  int getWriteHoldCount() const;
116 
125  int getReadHoldCount() const;
126 
142  bool hasWaiters(Condition* condition) const;
143 
156  int getWaitQueueLength(Condition* condition) const;
157 
166  std::string toString() const;
167 
176  bool hasQueuedThreads() const;
177 
191  bool hasQueuedThread(decaf::lang::Thread* thread) const;
192 
202  int getQueueLength() const;
203 
204  protected:
205 
217  decaf::util::Collection<decaf::lang::Thread*>* getWaitingThreads(Condition* condition) const;
218 
229  decaf::util::Collection<decaf::lang::Thread*>* getQueuedThreads() const;
230 
241  decaf::util::Collection<decaf::lang::Thread*>* getQueuedWriterThreads() const;
242 
253  decaf::util::Collection<decaf::lang::Thread*>* getQueuedReaderThreads() const;
254 
266  decaf::lang::Thread* getOwner() const;
267 
268  };
269 
270 }}}}
271 
272 #endif /* _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_ */
The root interface in the collection hierarchy.
Definition: Collection.h:68
Condition factors out the Mutex monitor methods (wait, notify and notifyAll) into distinct objects to...
Definition: Condition.h:132
A ReadWriteLock maintains a pair of associated locks, one for read-only operations and one for writin...
Definition: ReadWriteLock.h:90
A Thread is a concurrent unit of execution.
Definition: Thread.h:64
#define DECAF_API
Definition: Config.h:29
Definition: ReentrantReadWriteLock.h:38
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
Lock implementations provide more extensive locking operations than can be obtained using synchronize...
Definition: Lock.h:99