autohit.common.channels
Class QueuedDrain

java.lang.Object
  extended byautohit.common.channels.QueuedDrain
All Implemented Interfaces:
Drain

public class QueuedDrain
extends java.lang.Object
implements Drain

Basically, a queued drain. It is absolutely threadsafe. It can be used for interprocess communication.

Version:
1.0 Version HistoryEPG - Rewrite - 17Sep03
Author:
Erich P. Gatejen

Constructor Summary
QueuedDrain()
          Constructor
 
Method Summary
 Atom block()
          Block until there is something in the queue.
 Atom get()
          Get something from the queue.
 void init(java.lang.String name)
          Initializer
 boolean poll()
          Is there something available.
 Receipt post(Atom a)
          Post an item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueuedDrain

public QueuedDrain()
Constructor

Method Detail

init

public void init(java.lang.String name)
          throws ChannelException
Initializer

Parameters:
name - of the drain
Throws:
ChannelException

post

public Receipt post(Atom a)
             throws ChannelException
Post an item

Specified by:
post in interface Drain
Parameters:
a - An atom containing the posted data
Returns:
a receipt
Throws:
ChannelException

poll

public boolean poll()
Is there something available. There is no guarantee that between a poll() and a get() that there will still be something there.

Returns:
true if there is something in the queue, otherwise false

get

public Atom get()
         throws ChannelException
Get something from the queue. There is no guarantee that anything is there. If there isn't, it will return a null.

Returns:
An Atom or null
Throws:
ChannelException
See Also:
Atom

block

public Atom block()
           throws ChannelException
Block until there is something in the queue. It will always return something

Returns:
An Atom or null
Throws:
ChannelException
See Also:
Atom


Test.