Public Member Functions | |
ReferenceCountingLock () | |
boolean | acquire (long msecs) |
void | release () |
int | referenceCount () |
int | increment () |
int | decrement () |
Synchronization helper class used for activation/deactivation synchronization. This class enforces 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..."); }
com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.ReferenceCountingLock | ( | ) |
Constructor of ReferenceCountingLock
. After construction lock is free and reference count equals 1
.
boolean com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.acquire | ( | long | msecs | ) |
Attempt to acquire lock.
msecs | the number of milliseconds to wait. An argument less than or equal to zero means not to wait at all. |
true
if acquired, false
othwerwise. int com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.decrement | ( | ) |
Decrement number of references.
int com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.increment | ( | ) |
Increment number of references.
int com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.referenceCount | ( | ) |
Get number of references.
void com.cosylab.acs.maci.manager.ManagerImpl.ReferenceCountingLock.release | ( | ) |
Release previously acquired lock.