things.thinger.io.conduits.basic
Class BasicPullDrainContainer

java.lang.Object
  extended by things.thinger.io.conduits.basic.BasicPullDrainContainer
All Implemented Interfaces:
PullDrain, PullDrainContainer

public class BasicPullDrainContainer
extends java.lang.Object
implements PullDrainContainer

A basic implementation of a conduit drain container interface for a poller. This is the interface that the Conduit uses. The container manages threading, queuing, etc. The end user might only use the PullDrain interface.

Version:
1.0

Version History

EPG - Adapted from autohit - 29 JUN 05
 
Author:
Erich P. Gatejen

Constructor Summary
BasicPullDrainContainer()
           
 
Method Summary
 void init(ConduitID yourId)
          Initialize the PullDrain.
 boolean isDrained(Data n)
          Tell if a Nubblet has drained.
 Data poll()
          Poll for an item.
 Receipt postListener(Data n)
          Listen for a post.
 void waitForDrain()
          Wait for a drain.
 Data waitItem()
          Wait for an item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicPullDrainContainer

public BasicPullDrainContainer()
Method Detail

init

public void init(ConduitID yourId)
          throws SystemException
Initialize the PullDrain. This will be called by it's controller. An subsequent calls may result in a PANIC SystemException. Don't do it!

Specified by:
init in interface PullDrain
Parameters:
yourId - The ConduitID for this PullDrain.
Throws:
SystemException
See Also:
ConduitID

poll

public Data poll()
          throws SystemException
Poll for an item. It will return the item or null if it isn't there.

Specified by:
poll in interface PullDrain
Returns:
a Data or null if nothing is there.
Throws:
SystemException
See Also:
Data

waitItem

public Data waitItem()
              throws SystemException
Wait for an item. It will block until there is an item, when it will return it. However, it is possible that a ThingsException could intrerupt the block due to a FAULT.

Specified by:
waitItem in interface PullDrain
Returns:
a Data or null if nothing is there.
Throws:
SystemException
See Also:
Data

postListener

public Receipt postListener(Data n)
                     throws SystemException
Listen for a post. Consumers should implement this.

Specified by:
postListener in interface PullDrainContainer
Parameters:
n - The data to post.
Returns:
a receipt
Throws:
SystemException
See Also:
Data

isDrained

public boolean isDrained(Data n)
                  throws SystemException
Tell if a Nubblet has drained. If the Nubblet was never posted, it will treat it as it was drained.

Specified by:
isDrained in interface PullDrainContainer
Parameters:
n - The Nubblet to check.
Returns:
true if it is drained (or never was sent), otherwise false.
Throws:
SystemException
See Also:
Data

waitForDrain

public void waitForDrain()
Wait for a drain. If there are no pending drains, it'll immediately return.

Specified by:
waitForDrain in interface PullDrainContainer


Things.