00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTLOCK_H_
00019 #define _DECAF_UTIL_CONCURRENT_LOCKS_REENTRANTLOCK_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 #include <decaf/util/concurrent/locks/Lock.h>
00024 #include <decaf/util/Collection.h>
00025
00026 namespace decaf {
00027 namespace util {
00028 namespace concurrent {
00029 namespace locks {
00030
00031 class Sync;
00032
00080 class DECAF_API ReentrantLock : public Lock {
00081 private:
00082
00083
00084
00085 Sync* sync;
00086
00087 private:
00088
00089 ReentrantLock( const ReentrantLock& );
00090 ReentrantLock& operator= ( const ReentrantLock& );
00091
00092 public:
00093
00097 ReentrantLock();
00098
00105 ReentrantLock(bool fair);
00106
00107 virtual ~ReentrantLock();
00108
00124 virtual void lock();
00125
00158 virtual void lockInterruptibly();
00159
00181 virtual bool tryLock();
00182
00234 virtual bool tryLock( long long time, const TimeUnit& unit );
00235
00245 virtual void unlock();
00246
00269 virtual Condition* newCondition();
00270
00271 public:
00272
00304 int getHoldCount() const;
00305
00346 bool isHeldByCurrentThread() const;
00347
00354 bool isLocked() const;
00355
00361 bool isFair() const;
00362
00370 std::string toString() const;
00371
00379 int getQueueLength() const;
00380
00393 int getWaitQueueLength(Condition* condition) const;
00394
00405 bool hasWaiters(Condition* condition) const;
00406
00410 bool hasQueuedThreads() const;
00411
00418 bool hasQueuedThread(decaf::lang::Thread* thread) const;
00419
00420 protected:
00421
00433 decaf::util::Collection<decaf::lang::Thread*>* getWaitingThreads(Condition* condition) const;
00434
00445 decaf::lang::Thread* getOwner() const;
00446
00454 decaf::util::Collection<decaf::lang::Thread*>* getQueuedThreads() const;
00455
00456 };
00457
00458 }}}}
00459
00460 #endif