Build 1.0_r1(from source)

java.util.concurrent
Class Semaphore.Sync

java.lang.Object
  extended by java.util.concurrent.locks.AbstractQueuedSynchronizer
      extended by java.util.concurrent.Semaphore.Sync
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Semaphore.FairSync, Semaphore.NonfairSync
Enclosing class:
Semaphore

abstract static class Semaphore.Sync
extends AbstractQueuedSynchronizer

Synchronization implementation for semaphore. Uses AQS state to represent permits. Subclassed into fair and nonfair versions.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
 
Constructor Summary
Semaphore.Sync(int permits)
           
 
Method Summary
(package private)  int drainPermits()
           
(package private)  int getPermits()
           
(package private)  int nonfairTryAcquireShared(int acquires)
           
(package private)  void reducePermits(int reductions)
           
protected  boolean tryReleaseShared(int releases)
          Attempts to set the state to reflect a release in shared mode.
 
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireShared, tryAcquireSharedNanos, tryRelease
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Semaphore.Sync

Semaphore.Sync(int permits)
Method Detail

getPermits

final int getPermits()

nonfairTryAcquireShared

final int nonfairTryAcquireShared(int acquires)

tryReleaseShared

protected final boolean tryReleaseShared(int releases)
Description copied from class: AbstractQueuedSynchronizer
Attempts to set the state to reflect a release in shared mode.

This method is always invoked by the thread performing release.

The default implementation throws UnsupportedOperationException

Overrides:
tryReleaseShared in class AbstractQueuedSynchronizer
Parameters:
releases - the release argument. This value is always the one passed to a release method, or the current state value upon entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
true if this object is now in a fully released state, so that any waiting threads may attempt to acquire; and false otherwise.

reducePermits

final void reducePermits(int reductions)

drainPermits

final int drainPermits()

Build 1.0_r1(from source)

Please submit a feedback, bug or feature