org.norther.tammi.acorn.util.concurrent
Class ThresholdQueue
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.ArrayBlockingQueue
org.norther.tammi.acorn.util.concurrent.BoundedQueue
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. |
| Methods inherited from class java.util.concurrent.ArrayBlockingQueue |
clear, contains, drainTo, drainTo, iterator, peek, poll, remainingCapacity, remove, size, toArray, toArray, toString |
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.
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.