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
Abstract base class for semaphores relying on queued wait nodes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Base class for internal queue classes for semaphores, etc. -
Field Summary
FieldsFields 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
Modifier and TypeMethodDescriptionvoid
acquire()
Wait until a permit is available, and take oneboolean
attempt
(long msecs) Wait at most msecs millisconds for a permit.protected QueuedSemaphore.WaitQueue.WaitNode
protected boolean
precheck()
protected boolean
void
release()
Release a permitvoid
release
(long n) Release N permits
-
Field Details
-
wq_
-
-
Method Details
-
acquire
Description copied from class:Semaphore
Wait until a permit is available, and take one- Specified by:
acquire
in interfaceSync
- Overrides:
acquire
in classSemaphore
- Throws:
InterruptedException
-
attempt
Description copied from class:Semaphore
Wait at most msecs millisconds for a permit.- Specified by:
attempt
in interfaceSync
- Overrides:
attempt
in 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:
InterruptedException
-
precheck
protected boolean precheck() -
recheck
-
getSignallee
-
release
public void release()Description copied from class:Semaphore
Release a permit -
release
public void release(long n) Release N permits
-