solar.util
Class FastSyncQueue

java.lang.Object
  |
  +--solar.util.FastSyncQueue
All Implemented Interfaces:
Queue

public class FastSyncQueue
extends java.lang.Object
implements Queue

A synchronized blocking queue based on a fast linked-list. It turns out that using java.util.LinkedList to implement the queue is slower than using solar.util.ssLinkedList.

Version:
$Id: FastSyncQueue.java,v 1.2 2003/09/09 21:24:50 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  ssLinkedList _list
           
protected  int _size
           
 
Constructor Summary
FastSyncQueue()
           
 
Method Summary
 java.lang.Object dequeue()
          Dequeue one data item.
 java.lang.Object dequeue(long timeout)
          Dequeue one data item within timeout period.
 java.lang.Object[] dequeueAll()
          Dequeue all the data items currently in the queue.
 void enqueue(java.lang.Object item)
          Enqueue one data item.
 void enqueueAll(java.lang.Object[] items)
          Enqueue an array of data items.
 int size()
          Return the size of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_list

protected ssLinkedList _list

_size

protected int _size
Constructor Detail

FastSyncQueue

public FastSyncQueue()
Method Detail

size

public int size()
Description copied from interface: Queue
Return the size of the queue.

Specified by:
size in interface Queue

enqueue

public void enqueue(java.lang.Object item)
Description copied from interface: Queue
Enqueue one data item.

Specified by:
enqueue in interface Queue

enqueueAll

public void enqueueAll(java.lang.Object[] items)
Description copied from interface: Queue
Enqueue an array of data items.

Specified by:
enqueueAll in interface Queue

dequeue

public java.lang.Object dequeue()
                         throws java.lang.InterruptedException
Description copied from interface: Queue
Dequeue one data item.

Specified by:
dequeue in interface Queue
java.lang.InterruptedException

dequeue

public java.lang.Object dequeue(long timeout)
                         throws java.lang.InterruptedException
Description copied from interface: Queue
Dequeue one data item within timeout period.

Specified by:
dequeue in interface Queue
java.lang.InterruptedException

dequeueAll

public java.lang.Object[] dequeueAll()
Description copied from interface: Queue
Dequeue all the data items currently in the queue.

Specified by:
dequeueAll in interface Queue