activemq-cpp-3.9.5
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>
26
27namespace decaf {
28namespace util {
29namespace concurrent {
30namespace locks {
31
32 class ReentrantReadWriteLockImpl;
33
38 class DECAF_API ReentrantReadWriteLock : public ReadWriteLock {
39 private:
40
41 ReentrantReadWriteLockImpl* impl;
42
43 private:
44
45 ReentrantReadWriteLock(const ReentrantReadWriteLock&);
46 ReentrantReadWriteLock& operator=(const ReentrantReadWriteLock&);
47
48 public:
49
54
62
64
65 public:
66
71
76
82 bool isFair() const;
83
90 int getReadLockCount() const;
91
98 bool isWriteLocked() const;
99
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
192
202 int getQueueLength() const;
203
204 protected:
205
218
230
242
254
267
268 };
269
270}}}}
271
272#endif /* _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_ */
A Thread is a concurrent unit of execution.
Definition Thread.h:64
The root interface in the collection hierarchy.
Definition Collection.h:69
Condition factors out the Mutex monitor methods (wait, notify and notifyAll) into distinct objects to...
Definition Condition.h:132
Lock implementations provide more extensive locking operations than can be obtained using synchronize...
Definition Lock.h:99
A ReadWriteLock maintains a pair of associated locks, one for read-only operations and one for writin...
Definition ReadWriteLock.h:90
bool hasQueuedThreads() const
Queries whether any threads are waiting to acquire the read or write lock.
bool hasQueuedThread(decaf::lang::Thread *thread) const
Queries whether the given thread is waiting to acquire either the read or write lock.
decaf::util::Collection< decaf::lang::Thread * > * getQueuedReaderThreads() const
Returns a collection containing threads that may be waiting to acquire the read lock.
int getReadLockCount() const
Queries the number of read locks held for this lock.
decaf::lang::Thread * getOwner() const
Returns the thread that currently owns the write lock, or NULL if not owned.
bool isWriteLocked() const
Queries if the write lock is held by any thread.
virtual decaf::util::concurrent::locks::Lock & writeLock()
Returns the lock used for writing.the lock used for writing.
bool isFair() const
Returns true if this lock has fairness set true.
decaf::util::Collection< decaf::lang::Thread * > * getQueuedThreads() const
Returns a collection containing threads that may be waiting to acquire either the read or write lock.
int getQueueLength() const
Returns an estimate of the number of threads waiting to acquire either the read or write lock.
int getReadHoldCount() const
Queries the number of reentrant read holds on this lock by the current thread.
int getWaitQueueLength(Condition *condition) const
Gets an estimated count of the number of threads that are currently waiting on the given Condition ob...
virtual decaf::util::concurrent::locks::Lock & readLock()
Returns the lock used for reading.the lock used for reading.
decaf::util::Collection< decaf::lang::Thread * > * getQueuedWriterThreads() const
Returns a collection containing threads that may be waiting to acquire the write lock.
std::string toString() const
Returns a string identifying this lock, as well as its lock state.
bool hasWaiters(Condition *condition) const
Queries whether any threads are waiting on the given condition associated with the write lock.
int getWriteHoldCount() const
Queries the number of reentrant write holds on this lock by the current thread.
bool isWriteLockedByCurrentThread() const
Queries if the write lock is held by the current thread.
decaf::util::Collection< decaf::lang::Thread * > * getWaitingThreads(Condition *condition) const
Creates and returns a new Collection object that contains all the threads that may be waiting on the ...
ReentrantReadWriteLock(bool fair)
Creates a new ReentrantReadWriteLock with the given fairness policy.
ReentrantReadWriteLock()
Creates a new ReentrantReadWriteLock with the default ordering property of Not-Fair.
#define DECAF_API
Definition Config.h:29
Definition AbstractOwnableSynchronizer.h:29
Definition AbstractExecutorService.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25