Package com.yahoo.documentapi
Class ThroughputLimitQueue<M>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- java.util.concurrent.LinkedBlockingQueue<M>
-
- com.yahoo.documentapi.ThroughputLimitQueue<M>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<M>
,java.util.Collection<M>
,java.util.concurrent.BlockingQueue<M>
,java.util.Queue<M>
public class ThroughputLimitQueue<M> extends java.util.concurrent.LinkedBlockingQueue<M>
Queue that limits it's size based on the throughput. Allows the queue to keep a certain number of seconds of processing in its queue.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ThroughputLimitQueue(long queueSizeInMs)
Creates a new queue.ThroughputLimitQueue(com.yahoo.concurrent.Timer t, long queueSizeInMs)
Creates a new queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(M m)
boolean
addAll(java.util.Collection<? extends M> ms)
int
capacity()
boolean
offer(M m)
boolean
offer(M m, long l, java.util.concurrent.TimeUnit timeUnit)
M
poll()
M
poll(long l, java.util.concurrent.TimeUnit timeUnit)
void
put(M m)
int
remainingCapacity()
M
take()
-
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
clear, contains, drainTo, drainTo, forEach, iterator, peek, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
ThroughputLimitQueue
public ThroughputLimitQueue(long queueSizeInMs)
Creates a new queue.- Parameters:
queueSizeInMs
- The maximum time we wish to have objects waiting in the queue.
-
ThroughputLimitQueue
public ThroughputLimitQueue(com.yahoo.concurrent.Timer t, long queueSizeInMs)
Creates a new queue. Used for unit testing.- Parameters:
t
- Used to measure time spent in the queue. Subclass for unit testing, or use SystemTimer for regular use.queueSizeInMs
- The maximum time we wish to have objects waiting in the queue.
-
-
Method Detail
-
add
public boolean add(M m)
-
offer
public boolean offer(M m)
-
poll
public M poll()
-
put
public void put(M m) throws java.lang.InterruptedException
-
offer
public boolean offer(M m, long l, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
-
take
public M take() throws java.lang.InterruptedException
-
poll
public M poll(long l, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
-
capacity
public int capacity()
- Returns:
- Returns the maximum capacity of the queue
-
remainingCapacity
public int remainingCapacity()
-
-