`Ractor.receive` and `Ractor.yield` should stop when the
incoming/outgoing port is closed.
This commit is contained in:
Koichi Sasada 2024-11-05 11:49:21 +09:00
Родитель 4886a54d74
Коммит 0d63b9b4a4
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -753,7 +753,7 @@ ractor_wait_receive(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_racto
RACTOR_LOCK(cr);
{
while (ractor_queue_empty_p(cr, rq)) {
while (ractor_queue_empty_p(cr, rq) && !cr->sync.incoming_port_closed) {
ractor_sleep(ec, cr, wait_receiving);
}
}
@ -1364,6 +1364,9 @@ ractor_try_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_q
return true;
}
else if (cr->sync.outgoing_port_closed) {
rb_raise(rb_eRactorClosedError, "The outgoing-port is already closed");
}
else {
RUBY_DEBUG_LOG("no take basket");
return false;
@ -1375,7 +1378,7 @@ ractor_wait_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_
{
RACTOR_LOCK_SELF(cr);
{
while (!ractor_check_take_basket(cr, ts)) {
while (!ractor_check_take_basket(cr, ts) && !cr->sync.outgoing_port_closed) {
ractor_sleep(ec, cr, wait_yielding);
}
}