Package org.jcsp.lang

Class Guard

java.lang.Object
org.jcsp.lang.Guard
Direct Known Subclasses:
AltingBarrier, AltingChannelAccept, AltingChannelInput, AltingChannelInputInt, AltingChannelOutput, AltingChannelOutputInt, AltingConnectionClient, AltingConnectionServer, CSTimer, InlineAlternative, Skip, Stop

public abstract class Guard extends Object
This is the super-class for all Alternative events selectable by a process.

Description

Guard defines an abstract interface to be implemented by events competing for selection by a process executing an Alternative. Its methods have only package visibility within org.jcsp.lang and are of no concern to users of this package. Currently, JCSP supports channel inputs, accepts, timeouts and skips as guards.

Note: for those familiar with the occam multiprocessing language, classes implementing Guard correspond to process guards for use within ALT constructs.

See Also:
  • Constructor Details

    • Guard

      public Guard()
  • Method Details

    • enable

      abstract boolean enable(Alternative alt)
      Returns true if the event is ready. Otherwise, this enables the guard for selection and returns false.

      Note: this method should only be called by the Alternative class

      Parameters:
      alt - the Alternative class that is controlling the selection
      Returns:
      true if and only if the event is ready
    • disable

      abstract boolean disable()
      Disables the guard for selection. Returns true if the event was ready.

      Note: this method should only be called by the Alternative class

      Returns:
      true if and only if the event was ready
    • schedule

      protected void schedule(Alternative alt)
      Schedules the process performing the given Alternative to run again. This is intended for use by advanced users of the library who want to create their own Guards that are not in the org.jcsp.lang package.
      Parameters:
      alt - The Alternative to schedule