org.d_haven.event.command

Class SwitchedEnqueuePredicate

public class SwitchedEnqueuePredicate extends Object implements EnqueuePredicate

The SwitchedEnqueuePredicate provides a mechanism where we can explicitly tell the queue whether we are accepting new events or not. This EnqueuePredicate is useful in situations where you have to set the accept status based on certain events. One example of where this is used is in the CommandManager code.
Field Summary
booleanm_isAccepting
Constructor Summary
SwitchedEnqueuePredicate()
Create a SwitchedEnqueuePredicate.
Method Summary
booleanaccept(Object element, Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.
booleanaccept(Object[] elements, Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.
voidaccept()
Tell this EnqueuePredicate to start allowing new events to be enqueued.
voidblock()
Tell this EnqueuePredicate to start blocking new events to be enqueued.
StringtoString()

Field Detail

m_isAccepting

private volatile boolean m_isAccepting

Constructor Detail

SwitchedEnqueuePredicate

public SwitchedEnqueuePredicate()
Create a SwitchedEnqueuePredicate. The default status is to block all new events to a thread. If this is not what you want, then call the SwitchedEnqueuePredicate method.

Method Detail

accept

public boolean accept(Object element, Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.

Parameters: element The element to enqueue modifyingSink The sink that is used for this predicate

Returns: true if the sink accepts the element; false otherwise.

Since: Feb 10, 2003

accept

public boolean accept(Object[] elements, Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.

Parameters: elements The array of elements to enqueue modifyingSink The sink that is used for this predicate

Returns: true if the sink accepts all the elements; false otherwise.

Since: Feb 10, 2003

accept

public void accept()
Tell this EnqueuePredicate to start allowing new events to be enqueued.

block

public void block()
Tell this EnqueuePredicate to start blocking new events to be enqueued.

toString

public String toString()