pecan icon indicating copy to clipboard operation
pecan copied to clipboard

state is not correctly switched when @:pecan.accept returns synchronously

Open nadako opened this issue 4 years ago • 1 comments

@: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

nadako avatar Mar 31 '21 21:03 nadako

When I was working on haxe coroutines prototype I figured that we should set the next state before doing the suspending call.

nadako avatar Mar 31 '21 21:03 nadako