org.objectweb.dream.synchro
Interface ReadWriteLock

All Known Implementing Classes:
ReadWriteLockFIFOImpl

public interface ReadWriteLock

A read-write lock component aims at synchronizing the execution of several reader and writer components. Multiple reader components can concurrently read, so long as there are no writers. Only one writer component can write at a given time.

Note: This interface is freely inspired by Doug Lea's ReadWriteLock interface.


Field Summary
static String ITF_NAME
          The default name of the ReadWriteLockinterface.
 
Method Summary
 void acquireRead()
          Gets the read lock.
 void acquireWrite()
          Gets the write lock.
 boolean attemptRead(long msecs)
          Attempts to get the read lock.
 boolean attemptWrite(long msecs)
          Attempts to get the write lock.
 void releaseRead()
          Releases the read lock.
 void releaseWrite()
          Releases the write lock.
 

Field Detail

ITF_NAME

static final String ITF_NAME
The default name of the ReadWriteLockinterface.

See Also:
Constant Field Values
Method Detail

acquireRead

void acquireRead()
                 throws InterruptedException
Gets the read lock.

Throws:
InterruptedException - if the thread is interrupted while trying to acquire the lock.

releaseRead

void releaseRead()
Releases the read lock.


attemptRead

boolean attemptRead(long msecs)
                    throws InterruptedException
Attempts to get the read lock.

Parameters:
msecs - the number of milleseconds to wait. An argument less than or equal to zero means not to wait at all. However, this may still require access to a synchronization lock, which can impose unbounded delay if there is a lot of contention among threads.
Returns:
true if acquired.
Throws:
InterruptedException - if the thread is interrupted while waiting for the lock.

acquireWrite

void acquireWrite()
                  throws InterruptedException
Gets the write lock.

Throws:
InterruptedException - if the thread is interrupted while trying to acquire the lock.

releaseWrite

void releaseWrite()
Releases the write lock.


attemptWrite

boolean attemptWrite(long msecs)
                     throws InterruptedException
Attempts to get the write lock.

Parameters:
msecs - the number of milleseconds to wait. An argument less than or equal to zero means not to wait at all. However, this may still require access to a synchronization lock, which can impose unbounded delay if there is a lot of contention among threads.
Returns:
true if acquired.
Throws:
InterruptedException - if the thread is interrupted while waiting for the lock.


Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.