Public Member Functions | |
ReferenceCountingLock () | |
boolean | acquire (long msecs) |
void | release () |
int | referenceCount () |
int | increment () |
int | decrement () |
Private Attributes | |
AtomicInteger | references = new AtomicInteger(1) |
Lock | lock = new ReentrantLock() |
attempt
method of acquiring the locks to prevent deadlocks. Class also offers reference counting. (NOTE: automatic lock counting was not implemented due to imperfect usage.)
Example of usage: ReferenceCountingLock lock; if (lock.acquire(3*Sync.ONE_MINUTE)) { try { // critical section here } finally { lock.release(); } } else { throw new TimoutException("Deadlock detected..."); }
|
Constructor of |
|
Attempt to acquire lock.
|
|
Decrement number of references.
|
|
Increment number of references.
|
|
Get number of references.
|
|
Release previously acquired lock. |
|
Synchronization mutex. |
|
Number of current locks. |