EDU.oswego.cs.dl.util.concurrent
Class QueuedSemaphore

java.lang.Object
  extended by EDU.oswego.cs.dl.util.concurrent.Semaphore
      extended by 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.

[ Introduction to this package. ]


Nested Class Summary
protected static class QueuedSemaphore.WaitQueue
          Base class for internal queue classes for semaphores, etc.
 
Field Summary
protected  QueuedSemaphore.WaitQueue wq_
           
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.Semaphore
permits_
 
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
 void acquire()
          Wait until a permit is available, and take one
 boolean attempt(long msecs)
          Wait at most msecs millisconds for a permit.
protected  QueuedSemaphore.WaitQueue.WaitNode getSignallee()
           
protected  boolean precheck()
           
protected  boolean recheck(QueuedSemaphore.WaitQueue.WaitNode w)
           
 void release()
          Release a permit
 void release(long n)
          Release N permits
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.Semaphore
permits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wq_

protected final QueuedSemaphore.WaitQueue wq_
Method Detail

acquire

public void acquire()
             throws java.lang.InterruptedException
Description copied from class: Semaphore
Wait until a permit is available, and take one

Specified by:
acquire in interface Sync
Overrides:
acquire in class Semaphore
Throws:
java.lang.InterruptedException

attempt

public boolean attempt(long msecs)
                throws java.lang.InterruptedException
Description copied from class: Semaphore
Wait at most msecs millisconds for a permit.

Specified by:
attempt in interface Sync
Overrides:
attempt in class Semaphore
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: Semaphore
Release a permit

Specified by:
release in interface Sync
Overrides:
release in class Semaphore

release

public void release(long n)
Release N permits

Overrides:
release in class Semaphore