org.d_haven.event.impl

Class ThresholdEnqueuePredicate

public final class ThresholdEnqueuePredicate extends Object implements EnqueuePredicate

The ThresholdEnqueuePredicate limits the elements that can be enqueued based on the size of the Pipe.
Field Summary
intm_threshold
Constructor Summary
ThresholdEnqueuePredicate(int limit)
Create a new ThresholdEnqueuePredicate with the supplied limit.
Method Summary
booleanaccept(Object element, Sink modifyingSink)
Returns true if the Sink size + 1 (the element) is less than the threshold.
booleanaccept(Object[] elements, Sink modifyingSink)
Returns true if the Sink size + the number of elements is less than the threshold.
intgetThreshold()
Get the threshold size.
booleantestThreshold(Sink modifyingSink, int numElements)
StringtoString()

Field Detail

m_threshold

private final int m_threshold

Constructor Detail

ThresholdEnqueuePredicate

public ThresholdEnqueuePredicate(int limit)
Create a new ThresholdEnqueuePredicate with the supplied limit.

Parameters: limit A number greater than zero

Method Detail

accept

public boolean accept(Object element, Sink modifyingSink)
Returns true if the Sink size + 1 (the element) is less than the threshold.

Parameters: element the element being tested modifyingSink the sink to enqueue to

Returns: true if we are under the threshold

accept

public boolean accept(Object[] elements, Sink modifyingSink)
Returns true if the Sink size + the number of elements is less than the threshold.

Parameters: elements the elements being tested modifyingSink the sink to enqueue to

Returns: true if we are under the threshold

getThreshold

public int getThreshold()
Get the threshold size.

Returns: the threshold

testThreshold

private boolean testThreshold(Sink modifyingSink, int numElements)

toString

public String toString()