org.d_haven.event.command
Class SwitchedEnqueuePredicate

java.lang.Object
  extended by org.d_haven.event.command.SwitchedEnqueuePredicate
All Implemented Interfaces:
EnqueuePredicate

public class SwitchedEnqueuePredicate
extends java.lang.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
private  boolean m_isAccepting
           
 
Constructor Summary
SwitchedEnqueuePredicate()
          Create a SwitchedEnqueuePredicate.
 
Method Summary
 void accept()
          Tell this EnqueuePredicate to start allowing new events to be enqueued.
 boolean accept(java.lang.Object[] elements, Sink modifyingSink)
          Tests the given element for acceptance onto the m_sink.
 boolean accept(java.lang.Object element, Sink modifyingSink)
          Tests the given element for acceptance onto the m_sink.
 void block()
          Tell this EnqueuePredicate to start blocking new events to be enqueued.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 accept(java.lang.Object, org.d_haven.event.Sink) method.

Method Detail

accept

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

Specified by:
accept in interface EnqueuePredicate
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(java.lang.Object[] elements,
                      Sink modifyingSink)
Tests the given element for acceptance onto the m_sink.

Specified by:
accept in interface EnqueuePredicate
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

block

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


accept

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


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object