org.objectweb.dream.synchro
Class AbstractSemaphoreQueuedImpl
java.lang.Object
org.objectweb.dream.AbstractComponent
org.objectweb.dream.synchro.SemaphoreImpl
org.objectweb.dream.synchro.AbstractSemaphoreQueuedImpl
- All Implemented Interfaces:
- ContextualBindingController, NeedAsyncStartController, PrepareStopLifeCycleController, Loggable, Semaphore, SemaphoreAttributeController, AttributeController, BindingController, LifeCycleController
- Direct Known Subclasses:
- SemaphoreFIFOImpl
public class AbstractSemaphoreQueuedImpl
- extends SemaphoreImpl
Abstract implementation of a semaphore relying on queued wait nodes.
Note: Inspired by Doug Lea's implementation.
Methods inherited from class org.objectweb.dream.AbstractComponent |
beforeFirstStart, bindFc, 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 |
wq
protected final AbstractSemaphoreQueuedImpl.WaitQueue wq
acquire
public void acquire()
throws InterruptedException
- Description copied from interface:
Semaphore
- Waits until a permit is available, and take one
- Specified by:
acquire
in interface Semaphore
- Overrides:
acquire
in class SemaphoreImpl
- Throws:
InterruptedException
- if the thread is interrupted while trying to
acquire the permit.- See Also:
Semaphore.acquire()
attempt
public boolean attempt(long msecs)
throws InterruptedException
- Description copied from interface:
Semaphore
- Waits at most msecs millisconds for a permit.
- Specified by:
attempt
in interface Semaphore
- Overrides:
attempt
in class SemaphoreImpl
- 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 permit.- See Also:
Semaphore.attempt(long)
release
public void release()
- Description copied from interface:
Semaphore
- Release a permit
- Specified by:
release
in interface Semaphore
- Overrides:
release
in class SemaphoreImpl
- See Also:
Semaphore.release()
release
public void release(long n)
- Description copied from interface:
Semaphore
- Releases N permits.
- Specified by:
release
in interface Semaphore
- Overrides:
release
in class SemaphoreImpl
- Parameters:
n
- the number of permits to be released.- See Also:
Semaphore.release(long)
precheck
protected boolean precheck()
recheck
protected boolean recheck(AbstractSemaphoreQueuedImpl.WaitQueue.WaitNode w)
getSignallee
protected AbstractSemaphoreQueuedImpl.WaitQueue.WaitNode getSignallee()
listFc
public String[] listFc()
- Specified by:
listFc
in interface BindingController
- Overrides:
listFc
in class SemaphoreImpl
- See Also:
BindingController.listFc()
Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.