maslab.telemetry
Class MTQueue<T>

java.lang.Object
  extended by maslab.telemetry.MTQueue<T>

public class MTQueue<T>
extends java.lang.Object

A simple queue useful for transferring data from one thread to another in a safe way.


Constructor Summary
MTQueue()
          Create a new queue.
 
Method Summary
 T getBlock()
          Get the oldest object in the queue, waiting until an object is available if necessary.
 java.util.List<T> getList()
          Return a list-view of this queue.
 T getPoll()
          Get the oldest object in the queue, returning null if the queue is empty.
 void put(T o)
          Put a new object in the end of the queue.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTQueue

public MTQueue()
Create a new queue.

Method Detail

put

public void put(T o)
Put a new object in the end of the queue.

Parameters:
o - The object to enqueue.

getBlock

public T getBlock()
Get the oldest object in the queue, waiting until an object is available if necessary.

Returns:
The oldest object in the queue.

getPoll

public T getPoll()
Get the oldest object in the queue, returning null if the queue is empty.

Returns:
The oldest object in the queue.

getList

public java.util.List<T> getList()
Return a list-view of this queue. For thread safety, you must synchronize on the MTQueue object for the entire time that you operate on the underlying list.


size

public int size()