org.erights.e.elib.vat
Class SynchQueue

java.lang.Object
  |
  +--org.erights.e.elib.vat.Queue
        |
        +--org.erights.e.elib.vat.SynchQueue
All Implemented Interfaces:
Enumeration

public class SynchQueue
extends Queue

Untamed: A SynchQueue is a thread-safe Queue, providing its own lock, and a blocking dequeue() operation.

Since it provides a blocking operation, it is not E-safe. For an E-safe variant suitable for use inside one vat, see the superclass Queue.

Author:
Mark S. Miller
See Also:
org.erights.e.elib.vat.Vat

Field Summary
private  Object myQLock
           
 
Fields inherited from class org.erights.e.elib.vat.Queue
 
Constructor Summary
SynchQueue()
          Enabled: Makes a SynchQueue that can hold any object (except null).
SynchQueue(Class elementType)
          Enabled: Makes a SynchQueue that can hold objects of the specified elementType.
SynchQueue(Class elementType, Object qLock)
          Enabled: Provide the object to lock on.
 
Method Summary
 Object dequeue()
          Enabled: Get the least-recently-added element off of the queue.
 void enqueue(Object newElement)
          Enabled:
 boolean hasMoreElements()
          Enabled: Check to see if the queue has more elements.
 Object optDequeue()
          Enabled:
 
Methods inherited from class org.erights.e.elib.vat.Queue
nextElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Enumeration
asList, iterate
 

Field Detail

myQLock

private final Object myQLock
Constructor Detail

SynchQueue

public SynchQueue()
Enabled: Makes a SynchQueue that can hold any object (except null).


SynchQueue

public SynchQueue(Class elementType)
Enabled: Makes a SynchQueue that can hold objects of the specified elementType.

Parameters:
elementType - may not be a primitive (ie, scalar) type.

SynchQueue

public SynchQueue(Class elementType,
                  Object qLock)
Enabled: Provide the object to lock on.

Method Detail

dequeue

public Object dequeue()
Enabled: Get the least-recently-added element off of the queue. If the queue is currently empty, block until there is an element that can be dequeued.


enqueue

public void enqueue(Object newElement)
Enabled:

Overrides:
enqueue in class Queue
Parameters:
newElement - the object to be added to the end of the queue.

hasMoreElements

public boolean hasMoreElements()
Enabled: Check to see if the queue has more elements. This method allows a Queue to be used as an Enumeration.

Specified by:
hasMoreElements in interface Enumeration
Overrides:
hasMoreElements in class Queue
Returns:
is false if the queue is empty, otherwise true

optDequeue

public Object optDequeue()
Enabled:

Overrides:
optDequeue in class Queue


comments?