Build 1.0_r1(from source)

java.util.concurrent
Class SynchronousQueue.Node

java.lang.Object
  extended by java.util.concurrent.locks.AbstractQueuedSynchronizer
      extended by java.util.concurrent.SynchronousQueue.Node
All Implemented Interfaces:
Serializable
Enclosing class:
SynchronousQueue<E>

static final class SynchronousQueue.Node
extends AbstractQueuedSynchronizer

Nodes each maintain an item and handle waits and signals for getting and setting it. The class extends AbstractQueuedSynchronizer to manage blocking, using AQS state 0 for waiting, 1 for ack, -1 for cancelled.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
 
Field Summary
(package private)  Object item
          The item being transferred
(package private)  SynchronousQueue.Node next
          Next node in wait queue
 
Constructor Summary
SynchronousQueue.Node(Object x)
          Creates a node with initial item
SynchronousQueue.Node(Object x, SynchronousQueue.Node n)
          Creates a node with initial item and next
 
Method Summary
(package private)  Object getItem()
          Removes item from slot created by producer and signal producer to continue.
(package private)  boolean setItem(Object x)
          Fills in the slot created by the consumer and signal consumer to continue.
protected  boolean tryAcquire(int ignore)
          Implements AQS base acquire to succeed if not in WAITING state
protected  boolean tryRelease(int newState)
          Implements AQS base release to signal if state changed
(package private)  Object waitForPut()
          Waits for a producer to put item placed by consumer.
(package private)  Object waitForPut(long nanos)
          Waits for a producer to put item placed by consumer, or time out.
(package private)  void waitForTake()
          Waits for a consumer to take item placed by producer.
(package private)  boolean waitForTake(long nanos)
          Waits for a consumer to take item placed by producer or time out.
 
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, tryAcquireNanos, tryAcquireShared, tryAcquireSharedNanos, tryReleaseShared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

item

Object item
The item being transferred


next

SynchronousQueue.Node next
Next node in wait queue

Constructor Detail

SynchronousQueue.Node

SynchronousQueue.Node(Object x)
Creates a node with initial item


SynchronousQueue.Node

SynchronousQueue.Node(Object x,
                      SynchronousQueue.Node n)
Creates a node with initial item and next

Method Detail

tryAcquire

protected boolean tryAcquire(int ignore)
Implements AQS base acquire to succeed if not in WAITING state

Overrides:
tryAcquire in class AbstractQueuedSynchronizer
Parameters:
ignore - the acquire argument. This value is always the one passed to an acquire method, or is the value saved on entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
true if successful. Upon success, this object has been acquired.

tryRelease

protected boolean tryRelease(int newState)
Implements AQS base release to signal if state changed

Overrides:
tryRelease in class AbstractQueuedSynchronizer
Parameters:
newState - 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.

setItem

boolean setItem(Object x)
Fills in the slot created by the consumer and signal consumer to continue.


getItem

Object getItem()
Removes item from slot created by producer and signal producer to continue.


waitForTake

void waitForTake()
           throws InterruptedException
Waits for a consumer to take item placed by producer.

Throws:
InterruptedException

waitForPut

Object waitForPut()
            throws InterruptedException
Waits for a producer to put item placed by consumer.

Throws:
InterruptedException

waitForTake

boolean waitForTake(long nanos)
              throws InterruptedException
Waits for a consumer to take item placed by producer or time out.

Throws:
InterruptedException

waitForPut

Object waitForPut(long nanos)
            throws InterruptedException
Waits for a producer to put item placed by consumer, or time out.

Throws:
InterruptedException

Build 1.0_r1(from source)

Please submit a feedback, bug or feature