com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock Class Reference

Collaboration diagram for com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock:
Collaboration graph
[legend]

List of all members.

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()

Detailed Description

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..."); }


Constructor & Destructor Documentation

com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::ReferenceCountingLock (  )  [inline]

Constructor of ReferenceCountingLock. After construction lock is free and reference count equals 1.


Member Function Documentation

boolean com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::acquire ( long  msecs  )  [inline]

Attempt to acquire lock.

Parameters:
msecs the number of milliseconds to wait. An argument less than or equal to zero means not to wait at all.
Returns:
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.

Returns:
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.

Returns:
number of references.

References references.

Referenced by com::cosylab::acs::maci::manager::ManagerImpl::acquireSynchronizationObject().

int com::cosylab::acs::maci::manager::ManagerImpl::ReferenceCountingLock::referenceCount (  )  [inline]

Get number of references.

Returns:
number of references.

References references.

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().


Member Data Documentation

Synchronization mutex.

Referenced by acquire(), and release().

Number of current locks.

Referenced by decrement(), increment(), and referenceCount().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2