mirror of
https://github.com/janet-lang/janet
synced 2025-01-24 06:06:52 +00:00
Merge pull request #1182 from chris-chambers/channel-close-resumptions
This commit is contained in:
commit
5e152d30db
@ -1171,9 +1171,9 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
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 (writer.mode == JANET_CP_MODE_CHOICE_WRITE) {
|
||||||
janet_schedule(writer.fiber, janet_wrap_nil());
|
|
||||||
} else {
|
|
||||||
janet_schedule(writer.fiber, make_close_result(channel));
|
janet_schedule(writer.fiber, make_close_result(channel));
|
||||||
|
} else {
|
||||||
|
janet_schedule(writer.fiber, janet_wrap_nil());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1190,9 +1190,9 @@ JANET_CORE_FN(cfun_channel_close,
|
|||||||
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 (reader.mode == JANET_CP_MODE_CHOICE_READ) {
|
||||||
janet_schedule(reader.fiber, janet_wrap_nil());
|
|
||||||
} else {
|
|
||||||
janet_schedule(reader.fiber, make_close_result(channel));
|
janet_schedule(reader.fiber, make_close_result(channel));
|
||||||
|
} else {
|
||||||
|
janet_schedule(reader.fiber, janet_wrap_nil());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,5 +321,25 @@
|
|||||||
(assert (= item1 "hello"))
|
(assert (= item1 "hello"))
|
||||||
(assert (= item2 "world"))
|
(assert (= item2 "world"))
|
||||||
|
|
||||||
|
# ev/take, suspended, channel closed
|
||||||
|
(def ch (ev/chan))
|
||||||
|
(ev/go |(ev/chan-close ch))
|
||||||
|
(assert (= (ev/take ch) nil))
|
||||||
|
|
||||||
|
# ev/give, suspended, channel closed
|
||||||
|
(def ch (ev/chan))
|
||||||
|
(ev/go |(ev/chan-close ch))
|
||||||
|
(assert (= (ev/give ch 1) nil))
|
||||||
|
|
||||||
|
# ev/select, suspended take operation, channel closed
|
||||||
|
(def ch (ev/chan))
|
||||||
|
(ev/go |(ev/chan-close ch))
|
||||||
|
(assert (= (ev/select ch) [:close ch]))
|
||||||
|
|
||||||
|
# ev/select, suspended give operation, channel closed
|
||||||
|
(def ch (ev/chan))
|
||||||
|
(ev/go |(ev/chan-close ch))
|
||||||
|
(assert (= (ev/select [ch 1]) [:close ch]))
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user