org.apache.excalibur.event
Interface Source

All Known Subinterfaces:
Queue
All Known Implementing Classes:
AbstractQueue

public interface Source

A Source implements the side of an event queue where QueueElements are dequeued operations only.

The interface design is heavily influenced by Matt Welsh's SandStorm server, his demonstration of the SEDA architecture. We have deviated where we felt the design differences where better.

Author:
Avalon Development Team

Method Summary
 java.lang.Object dequeue()
          Dequeues the next element, or null if there is nothing left on the queue or in case of a timeout while attempting to obtain the mutex
 java.lang.Object[] dequeue(int num)
          Dequeues at most num available elements.
 java.lang.Object[] dequeueAll()
          Dequeues all available elements.
 void setTimeout(long millis)
          Sets the timeout on a blocking Source.
 int size()
          Returns the number of elements waiting in this Source.
 

Method Detail

setTimeout

public void setTimeout(long millis)
Sets the timeout on a blocking Source. Values above 1 will force all dequeue operations to block for up to that number of milliseconds waiting for new elements. Values below 1 will turn off blocking for Source. This is intentional because a Source should never block indefinitely.

Parameters:
millis - Number of milliseconds to block

dequeue

public java.lang.Object dequeue()
Dequeues the next element, or null if there is nothing left on the queue or in case of a timeout while attempting to obtain the mutex

Returns:
the next queue element on the Source

dequeueAll

public java.lang.Object[] dequeueAll()
Dequeues all available elements. Returns a zero-sized array in case of a timeout while attempting to obtain the mutex or if there is nothing left on the Source.

Returns:
all pending elements on the Source

dequeue

public java.lang.Object[] dequeue(int num)
Dequeues at most num available elements. Returns a zero-sized array in case of a timeout while attempting to obtain the mutex or if there is nothing left on the Source.

Parameters:
num - The maximum number of elements to dequeue
Returns:
At most num elements from the Source

size

public int size()
Returns the number of elements waiting in this Source.

Returns:
the number of elements in the Source


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.