|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.dream.AbstractComponent
org.objectweb.dream.synchro.ReadWriteLockFIFOImpl
public class ReadWriteLockFIFOImpl
FIFO implementation of the ReadWriteLock
interface. Threads contend
in a First-in/First-out manner for access. This lock is NOT reentrant.
Current readers and writers should not try to re-obtain locks while holding
them
Note: Inspired by Doug Lea's implementation.
Field Summary | |
---|---|
protected Semaphore |
entryLock
Fair Semaphore serving as a kind of mutual exclusion lock. |
protected int |
exreaders
Number of threads that have exited read lock. |
protected int |
readers
Number of threads that have entered read lock. |
Fields inherited from class org.objectweb.dream.AbstractComponent |
---|
bindingLogger, fcNeedAsyncStart, fcState, lifeCycleLogger, logger, weaveableC |
Fields inherited from interface org.objectweb.dream.synchro.ReadWriteLock |
---|
ITF_NAME |
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController |
---|
STARTED, STOPPED |
Constructor Summary | |
---|---|
ReadWriteLockFIFOImpl()
|
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 |
bindFc(String clientItfName,
Object serverItf)
|
String[] |
listFc()
|
void |
releaseRead()
Releases the read lock. |
void |
releaseWrite()
Releases the write lock. |
Methods inherited from class org.objectweb.dream.AbstractComponent |
---|
beforeFirstStart, bindFc, getFcNeedAsyncStart, getFcState, initComponent, lookupFc, prepareStopFc, setLogger, startFc, stopFc, unbindFc |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Semaphore entryLock
protected volatile int readers
protected int exreaders
Constructor Detail |
---|
public ReadWriteLockFIFOImpl()
Method Detail |
---|
public void acquireRead() throws InterruptedException
ReadWriteLock
acquireRead
in interface ReadWriteLock
InterruptedException
- if the thread is interrupted while trying to
acquire the lock.ReadWriteLock.acquireRead()
public void releaseRead()
ReadWriteLock
releaseRead
in interface ReadWriteLock
ReadWriteLock.releaseRead()
public void acquireWrite() throws InterruptedException
ReadWriteLock
acquireWrite
in interface ReadWriteLock
InterruptedException
- if the thread is interrupted while trying to
acquire the lock.ReadWriteLock.acquireWrite()
public void releaseWrite()
ReadWriteLock
releaseWrite
in interface ReadWriteLock
ReadWriteLock.releaseWrite()
public boolean attemptRead(long msecs) throws InterruptedException
ReadWriteLock
attemptRead
in interface ReadWriteLock
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.
InterruptedException
- if the thread is interrupted while waiting for
the lock.ReadWriteLock.attemptRead(long)
public boolean attemptWrite(long msecs) throws InterruptedException
ReadWriteLock
attemptWrite
in interface ReadWriteLock
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.
InterruptedException
- if the thread is interrupted while waiting for
the lock.ReadWriteLock.attemptWrite(long)
public void bindFc(String clientItfName, Object serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException
bindFc
in interface BindingController
bindFc
in class AbstractComponent
NoSuchInterfaceException
IllegalBindingException
IllegalLifeCycleException
BindingController.bindFc(java.lang.String,
java.lang.Object)
public String[] listFc()
listFc
in interface BindingController
BindingController.listFc()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |