Next: Blocking in system context, Previous: Multiple provides, Up: Execution Semantics [Contents][Index]
The blocking keyword can (since 2.15) also be used in combination
with multiple provides ports.  In our explanation we will
introduce a component that does two things.  First it multiplexes the
provides ports events over a single requires port.
Secondly it maps the synchronous behavior of the provides
ihello interfaces onto the asynchronous behavior of the
requires iworld interface (see the interface declarations
at the end of this section).
import ihello.dzn;
import iworld.dzn;
component blocking_multiple_provides
{
  provides blocking ihello left;
  provides blocking ihello right;
  requires iworld r;
  behavior
  {
    enum Side {None, Left, Right};
    Side side = Side.None;
    Side pending = Side.None;
    [side.None]
    {
      blocking on left.hello(): {r.hello(); side = Side.Left;}
      blocking on right.hello(): {r.hello(); side = Side.Right;}
    }
    [side.Left] blocking on right.hello(): pending = Side.Right;
    [side.Right] blocking on left.hello(): pending = Side.Left;
    on r.world():
    {
      if(side.Left) left.reply();
      if(side.Right) right.reply();
      if(!pending.None) r.hello();
      side = pending;
      pending = Side.None;
    }
  }
}
In the event sequence trace below we can see that for each
provides port that asynchronous hello world
transaction is encapsulated.
