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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user