Class BlockManager

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

public class BlockManager extends Object
Manages multiple blocking code segments simultaneously such that unblocking one block condition releases the block of all other block code segments.
Author:
Danny Daglas
See Also:
  • Constructor Details

    • BlockManager

      public BlockManager()
  • Method Details

    • block

      public String block(BlockObject bo)
      Executes all block segments simultaneously, waiting for one block release.

      The algorithm is as follows:

      • Collect linked block objects into a List.
      • Spawn a BlockThread for each block object.
      • Wait for notification from any of the BlockThreads.
      • Interrupt remaining block threads.
      • Wait for each BlockThread to die.
      • Return the block object notifier which satisfied their block condition.

      And, the BlockThread algorithm is as follows:

      • try, catch for InterruptedException ...
        • Execute the BlockObject block segment.
        • Assign the notifier from this BlockObject if one isn't already assigned (to mitigate a race condition).
        • Notify the BlockManager.
      • If interrupted, do nothing and return.
      Parameters:
      bo - BlockObject to employ. Other block objects may be linked to this block object. In this event, employ all block objects simultaneously.
      Returns:
      a String object