Waiting for Events Next: Preemption Up: Event Based Instructions Previous: Control Instruction

Waiting for Events

Await  extends Instruction and contains a Config field. The activation method returns SUSP while the configuration is not fixed, then it evaluates it. If evaluation returns false, meaning that the configuration waited for is not satisfied, then the method stops. If evaluation returns true, meaning that the configuration waited for is satisfied, then the Await terminates and returns TERM if the end of the current instant is not already reached, STOP otherwise. For example evaluation of the configuration corresponding to ``not e'' returns true if e was not generated, and activation returns STOP in this case. This is coherentwith the basic principle of 4.1 which states that the absence of an event cannot be decided before the end of the current instant.

 
public class Await extends Instruction
{
  private Config config;

  public Await(Config config){ this.config = config; }
  final public String toString(){ return "await " + config; }

  final public boolean equals(Instruction inst){
    return  super.equals(inst) && 
            config.equals(((Await)inst).config);
  }

  final protected byte activation(Machine machine) 
  { 
    if (!config.fixed(machine)) return SUSP; 
    if (!config.evaluate(machine)) return STOP;
    terminate();
    return machine.isEndOfInstant() ? STOP : TERM;
  }
}