Package EDU.oswego.cs.dl.util.concurrent
Class QueuedSemaphore
- java.lang.Object
-
- EDU.oswego.cs.dl.util.concurrent.Semaphore
-
- EDU.oswego.cs.dl.util.concurrent.QueuedSemaphore
-
- All Implemented Interfaces:
Sync
- Direct Known Subclasses:
FIFOSemaphore,PrioritySemaphore
public abstract class QueuedSemaphore extends Semaphore
Abstract base class for semaphores relying on queued wait nodes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classQueuedSemaphore.WaitQueueBase class for internal queue classes for semaphores, etc.
-
Field Summary
Fields Modifier and Type Field Description protected QueuedSemaphore.WaitQueuewq_-
Fields inherited from interface EDU.oswego.cs.dl.util.concurrent.Sync
ONE_CENTURY, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ONE_YEAR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquire()Wait until a permit is available, and take onebooleanattempt(long msecs)Wait at most msecs millisconds for a permit.protected QueuedSemaphore.WaitQueue.WaitNodegetSignallee()protected booleanprecheck()protected booleanrecheck(QueuedSemaphore.WaitQueue.WaitNode w)voidrelease()Release a permitvoidrelease(long n)Release N permits
-
-
-
Field Detail
-
wq_
protected final QueuedSemaphore.WaitQueue wq_
-
-
Method Detail
-
acquire
public void acquire() throws java.lang.InterruptedExceptionDescription copied from class:SemaphoreWait until a permit is available, and take one
-
attempt
public boolean attempt(long msecs) throws java.lang.InterruptedExceptionDescription copied from class:SemaphoreWait at most msecs millisconds for a permit.- Specified by:
attemptin interfaceSync- Overrides:
attemptin classSemaphore- 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:
java.lang.InterruptedException
-
precheck
protected boolean precheck()
-
recheck
protected boolean recheck(QueuedSemaphore.WaitQueue.WaitNode w)
-
getSignallee
protected QueuedSemaphore.WaitQueue.WaitNode getSignallee()
-
release
public void release()
Description copied from class:SemaphoreRelease a permit
-
-