Package EDU.oswego.cs.dl.util.concurrent
Class FIFOSemaphore
- java.lang.Object
-
- EDU.oswego.cs.dl.util.concurrent.Semaphore
-
- EDU.oswego.cs.dl.util.concurrent.QueuedSemaphore
-
- EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore
-
- All Implemented Interfaces:
Sync
public class FIFOSemaphore extends QueuedSemaphore
A First-in/First-out implementation of a Semaphore. Waiting requests will be satisified in the order that the processing of those requests got to a certain point. If this sounds vague it is meant to be. FIFO implies a logical timestamping at some point in the processing of the request. To simplify things we don't actually timestamp but simply store things in a FIFO queue. Thus the order in which requests enter the queue will be the order in which they come out. This order need not have any relationship to the order in which requests were made, nor the order in which requests actually return to the caller. These depend on Java thread scheduling which is not guaranteed to be predictable (although JVMs tend not to go out of their way to be unfair).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
FIFOSemaphore.FIFOWaitQueue
Simple linked list queue used in FIFOSemaphore.-
Nested classes/interfaces inherited from class EDU.oswego.cs.dl.util.concurrent.QueuedSemaphore
QueuedSemaphore.WaitQueue
-
-
Field Summary
-
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.QueuedSemaphore
wq_
-
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
-
-
Constructor Summary
Constructors Constructor Description FIFOSemaphore(long initialPermits)
Create a Semaphore with the given initial number of permits.
-
Method Summary
-
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.QueuedSemaphore
acquire, attempt, getSignallee, precheck, recheck, release, release
-
-
-
-
Constructor Detail
-
FIFOSemaphore
public FIFOSemaphore(long initialPermits)
Create a Semaphore with the given initial number of permits. Using a seed of one makes the semaphore act as a mutual exclusion lock. Negative seeds are also allowed, in which case no acquires will proceed until the number of releases has pushed the number of permits past 0.
-
-