
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() |
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 | ( | ) | [inline] |
Constructor of ReferenceCountingLock. After construction lock is free and reference count equals 1.
| boolean com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::acquire | ( | long | msecs | ) | [inline] |
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. References lock.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::acquireSynchronizationObject().
| int com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::decrement | ( | ) | [inline] |
Decrement number of references.
References references.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::releaseSynchronizationObject().
| int com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::increment | ( | ) | [inline] |
Increment number of references.
References references.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::acquireSynchronizationObject().
| int com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::referenceCount | ( | ) | [inline] |
| void com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::release | ( | ) | [inline] |
Release previously acquired lock.
References lock.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::releaseSynchronizationObject().
Lock com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::lock = new ReentrantLock() [private] |
AtomicInteger com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::references = new AtomicInteger(1) [private] |
Number of current locks.
Referenced by decrement(), increment(), and referenceCount().
1.6.2