States
Any coroutine instance is in one of the following states, which can be checked with the state variable:
Ready- running or just created withrunSuspended(...)and not yettick()ed.Suspended- suspended with asuspend()call (or similar).Accepting- waiting for a value after anaccept()call.Yielding- waiting to provide a value with ayield(...)call.Expecting- waiting for a value after a custom accept call.Terminated- finished, cannot be woken up again.
Return value
If a coroutine terminated with a return statement, the returned value is available in the returned field. Otherwise, the field is set to null. Coroutines that return Void will have returned with a type of pecan.Void.
Example: returned usage
var adder = pecan.Co.co(function():String {
  var x = accept();
  var y = accept();
  return '$x + $y = ${x + y}';
}, (_ : Int));
var instance = adder.run();
instance.give(1);
instance.give(2);
trace(instance.returned); // output: 1 + 2 = 3