org.jawk.jrt
Class BlockObject

java.lang.Object
  extended by org.jawk.jrt.BlockObject
Direct Known Subclasses:
BulkBlockObject

public abstract class BlockObject
extends java.lang.Object

An item which blocks until something useful can be done with the object. The BlockManager multiplexes BlockObjects such that unblocking one BlockObject causes the BlockManager to dispatch the notifier tag result of the BlockObject.

BlockObjects are chained. The BlockManager blocks on all chained BlockObjects until one is unblocked.

Subclasses must provide meaningful block() and getNotifierTag() routines.

BlockObjects do not actually perform the client blocking. This is done by the BlockManager at the AVM (interpreted) or compiled runtime environment. The AVM/compiled environments make special provision to return the head block object to the BlockManager (within _EXTENSION_ keyword processing).

See Also:
BlockManager, BulkBlockObject

Constructor Summary
protected BlockObject()
           
 
Method Summary
abstract  void block()
          Block until meaningful data is made available for the client application.
 void clearNextBlockObject()
          Eliminate the rest of the BlockObject chain.
 java.util.List<BlockObject> getBlockObjects()
          Obtain all chained BlockObjects as a List, including this one.
abstract  java.lang.String getNotifierTag()
          Construct a meaningful notifier tag for this BlockObject.
 void setNextBlockObject(BlockObject bo)
          Chain this BlockObject to another BlockObject.
 java.lang.String toString()
          Ensure non-evaluation of a BlockObject by throwing an AWK Runtime exception, in case it leaks into AWK evaluation space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockObject

protected BlockObject()
Method Detail

getNotifierTag

public abstract java.lang.String getNotifierTag()
Construct a meaningful notifier tag for this BlockObject.


block

public abstract void block()
                    throws java.lang.InterruptedException
Block until meaningful data is made available for the client application. This is called by the BlockManager in a way such that the BlockManager waits for one BlockObject to unblock.

Throws:
java.lang.InterruptedException

clearNextBlockObject

public void clearNextBlockObject()
Eliminate the rest of the BlockObject chain.


setNextBlockObject

public void setNextBlockObject(BlockObject bo)
Chain this BlockObject to another BlockObject. The chain is linear and there is no upper bounds on the number of BlockObjects that can be supported.


getBlockObjects

public java.util.List<BlockObject> getBlockObjects()
                                            throws AwkRuntimeException
Obtain all chained BlockObjects as a List, including this one. A BlockObject chain cycle causes a runtime exception to be thrown.

Returns:
A List of chained BlockObjects, including this one.
Throws:
AwkRuntimeException - if the BlockObject chain contains a cycle.

toString

public final java.lang.String toString()
Ensure non-evaluation of a BlockObject by throwing an AWK Runtime exception, in case it leaks into AWK evaluation space.

Overrides:
toString in class java.lang.Object