00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_ 00019 #define _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_ 00020 00021 #include <decaf/util/Config.h> 00022 00023 #include <decaf/lang/Thread.h> 00024 #include <decaf/util/Collection.h> 00025 #include <decaf/util/concurrent/locks/ReadWriteLock.h> 00026 00027 namespace decaf { 00028 namespace util { 00029 namespace concurrent { 00030 namespace locks { 00031 00032 class ReentrantReadWriteLockImpl; 00033 00038 class DECAF_API ReentrantReadWriteLock : public ReadWriteLock { 00039 private: 00040 00041 ReentrantReadWriteLockImpl* impl; 00042 00043 private: 00044 00045 ReentrantReadWriteLock(const ReentrantReadWriteLock&); 00046 ReentrantReadWriteLock& operator=(const ReentrantReadWriteLock&); 00047 00048 public: 00049 00053 ReentrantReadWriteLock(); 00054 00061 ReentrantReadWriteLock(bool fair); 00062 00063 virtual ~ReentrantReadWriteLock(); 00064 00065 public: 00066 00070 virtual decaf::util::concurrent::locks::Lock& readLock(); 00071 00075 virtual decaf::util::concurrent::locks::Lock& writeLock(); 00076 00082 bool isFair() const; 00083 00090 int getReadLockCount() const; 00091 00098 bool isWriteLocked() const; 00099 00105 bool isWriteLockedByCurrentThread() const; 00106 00115 int getWriteHoldCount() const; 00116 00125 int getReadHoldCount() const; 00126 00142 bool hasWaiters(Condition* condition) const; 00143 00156 int getWaitQueueLength(Condition* condition) const; 00157 00166 std::string toString() const; 00167 00176 bool hasQueuedThreads() const; 00177 00191 bool hasQueuedThread(decaf::lang::Thread* thread) const; 00192 00202 int getQueueLength() const; 00203 00204 protected: 00205 00217 decaf::util::Collection<decaf::lang::Thread*>* getWaitingThreads(Condition* condition) const; 00218 00229 decaf::util::Collection<decaf::lang::Thread*>* getQueuedThreads() const; 00230 00241 decaf::util::Collection<decaf::lang::Thread*>* getQueuedWriterThreads() const; 00242 00253 decaf::util::Collection<decaf::lang::Thread*>* getQueuedReaderThreads() const; 00254 00266 decaf::lang::Thread* getOwner() const; 00267 00268 }; 00269 00270 }}}} 00271 00272 #endif /* _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTREADWRITELOCK_H_ */
1.6.1