pecan
pecan copied to clipboard
state is not correctly switched when @:pecan.accept returns synchronously
@:pecan.accept function sync(?ret:pecan.Void->Void, ?co:pecan.ICo<Any, Any, Any>):pecan.Void {
ret(Void);
return null;
}
@:pecan.accept function async(?ret:pecan.Void->Void, ?co:pecan.ICo<Any, Any, Any>):pecan.Void {
haxe.Timer.delay(() -> ret(Void), 10);
return null;
}
function main() {
pecan.Co.co({
sync();
trace("hallo");
async();
}).run();
}
Output:
src/Main.hx:14: hallo
src/Main.hx:14: hallo
When I was working on haxe coroutines prototype I figured that we should set the next state before doing the suspending call.