1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-05 10:03:06 +00:00

Mark a fiber as a root fiber during scheduling, not resumption.

This is more intuitive and avoids the possibilty of strange code
to resume or cancel a fiber after it was scheduled but before it was
entered for the first time.
This commit is contained in:
Calvin Rose
2022-02-10 17:40:08 -06:00
parent aba87bf1bd
commit 2f068b91d8
2 changed files with 4 additions and 5 deletions

View File

@@ -465,6 +465,7 @@ const JanetAbstractType janet_stream_type = {
/* Register a fiber to resume with value */
void janet_schedule_signal(JanetFiber *fiber, Janet value, JanetSignal sig) {
if (fiber->gc.flags & JANET_FIBER_EV_FLAG_CANCELED) return;
fiber->gc.flags |= JANET_FIBER_FLAG_ROOT;
JanetTask t = { fiber, value, sig, ++fiber->sched_id };
if (sig == JANET_SIGNAL_ERROR) fiber->gc.flags |= JANET_FIBER_EV_FLAG_CANCELED;
janet_q_push(&janet_vm.spawn, &t, sizeof(t));