org.norther.tammi.acorn.util.concurrent
Class ThresholdQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.concurrent.ArrayBlockingQueue
              extended by org.norther.tammi.acorn.util.concurrent.BoundedQueue
                  extended by org.norther.tammi.acorn.util.concurrent.ThresholdQueue
All Implemented Interfaces:
Serializable, Iterable, Collection, BlockingQueue, Queue

public class ThresholdQueue
extends BoundedQueue

A blocking queue class, which signals takes and polls only when a preset inclusive threshold of its capacity is reached.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
ThresholdQueue(int capacity, double thresh)
          Creates a queue with the specified capacity.
ThresholdQueue(int capacity, double thresh, boolean fair)
          Creates a new queue with the specified capacity and access policy.
ThresholdQueue(int capacity, double thresh, boolean fair, Collection c)
          Creates a new queue with the specified capacity, access policy and initial collection.
 
Method Summary
 boolean offer(Object o)
           
 boolean offer(Object o, long timeout, TimeUnit unit)
           
 Object poll(long timeout, TimeUnit unit)
           
 void put(Object o)
           
 Object take()
           
 
Methods inherited from class java.util.concurrent.ArrayBlockingQueue
clear, contains, drainTo, drainTo, iterator, peek, poll, remainingCapacity, remove, size, toArray, toArray, toString
 
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll
 

Constructor Detail

ThresholdQueue

public ThresholdQueue(int capacity,
                      double thresh)
Creates a queue with the specified capacity.

Parameters:
capacity - the capacity.
thresh - the treshold (0.0 - 1.0)

ThresholdQueue

public ThresholdQueue(int capacity,
                      double thresh,
                      boolean fair)
Creates a new queue with the specified capacity and access policy.

Parameters:
capacity - the capacity.
thresh - the treshold (0.0 - 1.0)
fair - true for FIFO, false for unspecified.

ThresholdQueue

public ThresholdQueue(int capacity,
                      double thresh,
                      boolean fair,
                      Collection c)
Creates a new queue with the specified capacity, access policy and initial collection.

Parameters:
capacity - the capacity.
thresh - the treshold (0.0 - 1.0)
fair - true for FIFO, false for unspecified.
c - the initial collection of items.
Method Detail

offer

public boolean offer(Object o)
Specified by:
offer in interface BlockingQueue
Specified by:
offer in interface Queue
Overrides:
offer in class ArrayBlockingQueue

offer

public boolean offer(Object o,
                     long timeout,
                     TimeUnit unit)
              throws InterruptedException
Specified by:
offer in interface BlockingQueue
Overrides:
offer in class ArrayBlockingQueue
Throws:
InterruptedException

poll

public Object poll(long timeout,
                   TimeUnit unit)
            throws InterruptedException
Specified by:
poll in interface BlockingQueue
Overrides:
poll in class ArrayBlockingQueue
Throws:
InterruptedException

put

public void put(Object o)
         throws InterruptedException
Specified by:
put in interface BlockingQueue
Overrides:
put in class ArrayBlockingQueue
Throws:
InterruptedException

take

public Object take()
            throws InterruptedException
Specified by:
take in interface BlockingQueue
Overrides:
take in class ArrayBlockingQueue
Throws:
InterruptedException


Copyright © 2004 The Norther Organization. All rights reserved.