mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Address #1405 - don't try and resume fibers that can't be resumed.
FOr fibers that _can_ be resumed and then get cancelled, the sched_id will be incremented later prevent the spurious wake ups.
This commit is contained in:
parent
e66dc14b3a
commit
c9897f99c3
@ -1166,10 +1166,12 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
msg.argj = janet_wrap_nil();
|
msg.argj = janet_wrap_nil();
|
||||||
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
||||||
} else {
|
} else {
|
||||||
if (writer.mode == JANET_CP_MODE_CHOICE_WRITE) {
|
if (janet_fiber_can_resume(writer.fiber)) {
|
||||||
janet_schedule(writer.fiber, make_close_result(channel));
|
if (writer.mode == JANET_CP_MODE_CHOICE_WRITE) {
|
||||||
} else {
|
janet_schedule(writer.fiber, make_close_result(channel));
|
||||||
janet_schedule(writer.fiber, janet_wrap_nil());
|
} else {
|
||||||
|
janet_schedule(writer.fiber, janet_wrap_nil());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1185,10 +1187,12 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
msg.argj = janet_wrap_nil();
|
msg.argj = janet_wrap_nil();
|
||||||
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
janet_ev_post_event(vm, janet_thread_chan_cb, msg);
|
||||||
} else {
|
} else {
|
||||||
if (reader.mode == JANET_CP_MODE_CHOICE_READ) {
|
if (janet_fiber_can_resume(reader.fiber)) {
|
||||||
janet_schedule(reader.fiber, make_close_result(channel));
|
if (reader.mode == JANET_CP_MODE_CHOICE_READ) {
|
||||||
} else {
|
janet_schedule(reader.fiber, make_close_result(channel));
|
||||||
janet_schedule(reader.fiber, janet_wrap_nil());
|
} else {
|
||||||
|
janet_schedule(reader.fiber, janet_wrap_nil());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user