pecan

pecan.CoTools

pecan.CoTools provides static extension to pecan.ICo<...> instances. It is added to coroutine instances using @:using(...), so it need not be imported with using pecan.CoTools;.

public static function await<T>(waitFor):T

This is a @:pecan.accept function that can be used from within a coroutine to wait for the completion of another coroutine.

Example: await usage

var a = pecan.Co.co(function():String {
  suspend();
  return "Haxe";
}).run();
var b = pecan.Co.co({
  var result = a.await();
  trace('Hello, $result!');
}).run();
a.wakeup(); // output: Hello, Haxe!
« Previous: pecan.ICo Next: Implementation details »