See Original text in context
method wait(Supply:)
Taps the Supply
it is called on, and blocks execution until the either the supply is done
(in which case it evaluates to the final value that was emitted on the Supply
, or Nil
if not value was emitted) or quit
(in which case it will throw the exception that was passed to quit
).
my = Supplier.new;start.Supply.wait;say "Two seconds: done";
See Original text in context
multi method wait( --> Nil )multi method wait( --> Nil )
Without any predicate, it waits on the condition variable itself; with a predicate, waits until the code returns a truish value.
my = 100;my ;my ;for ^
The condition we obtain from the $l
lock is awaited using a predicate, in this case, check if the counter is still zero. When it takes another value, the program flow continues in the next instruction.