org.compass.core.util.backport.java.util.concurrent
Class SynchronousQueue.Node

java.lang.Object
  extended by org.compass.core.util.backport.java.util.concurrent.SynchronousQueue.Node
All Implemented Interfaces:
Serializable
Enclosing class:
SynchronousQueue

static final class SynchronousQueue.Node
extends Object
implements Serializable

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.


Field Summary
(package private)  Object item
          The item being transferred
(package private)  SynchronousQueue.Node next
          Next node in wait queue
(package private)  int state
           
 
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.
(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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

int state

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

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


Copyright (c) 2004-2006 The Compass Project.