Class BlockObject

java.lang.Object
org.sentrysoftware.jawk.jrt.BlockObject

public abstract class BlockObject extends 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).

Author:
Danny Daglas
See Also:
  • Method Details

    • getNotifierTag

      public abstract String getNotifierTag()
      Construct a meaningful notifier tag for this BlockObject.
      Returns:
      a String object
    • block

      public abstract void block() throws 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:
      InterruptedException - if any.
    • clearNextBlockObject

      public final 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.
      Parameters:
      bo - a BlockObject object
    • getBlockObjects

      public List<BlockObject> getBlockObjects()
      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 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 Object