mirror of
https://github.com/janet-lang/janet
synced 2026-02-06 02:00:22 +00:00
Disallow scheduling already modified fibers.
While not strictly needed for correctness, this discourages misuse of fibers and mixing both coroutine, error handling, and scheduling purposes.
This commit is contained in:
@@ -3038,6 +3038,9 @@ JANET_CORE_FN(cfun_ev_go,
|
||||
fiber->env->proto = janet_vm.fiber->env;
|
||||
} else {
|
||||
fiber = janet_getfiber(argv, 0);
|
||||
if (janet_fiber_status(fiber) != JANET_STATUS_NEW) {
|
||||
janet_panic("can only schedule new fibers where (= (fiber/status f) :new)");
|
||||
}
|
||||
}
|
||||
fiber->supervisor_channel = supervisor;
|
||||
janet_schedule(fiber, value);
|
||||
|
||||
@@ -78,4 +78,10 @@
|
||||
(ev/sleep 0.1) # can we do better?
|
||||
(assert (= 0 (ev/count supervisor)) "empty supervisor")
|
||||
|
||||
# Issue #1707
|
||||
(def f (coro (repeat 10 (yield 1))))
|
||||
(resume f)
|
||||
(assert-error "cannot schedule non-new fiber"
|
||||
(ev/go f))
|
||||
|
||||
(end-suite)
|
||||
|
||||
Reference in New Issue
Block a user