diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-09-14 10:30:22 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-09-15 00:04:59 +0900 |
commit | f7ccb8dd88c52b2294742c3abb87098ee4076799 (patch) | |
tree | 22b4a10cce30cf227bc6354e9adab7c3a5284335 /ractor.c | |
parent | edb5c67195129e1d10f329edb55e486e1874b20e (diff) |
restart Ractor.select on intterupt
signal can interrupt Ractor.select, but if there is no exception,
Ractor.select should restart automatically.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3534
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -877,6 +877,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield VALUE crv = cr->self; VALUE ret = Qundef; int i; + bool interrupted = false; enum ractor_wait_status wait_status = 0; bool yield_p = (yielded_value != Qundef) ? true : false; @@ -914,6 +915,8 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield } rs = NULL; + restart: + if (yield_p) { actions[i].type = ractor_select_action_yield; actions[i].v = Qundef; @@ -1079,6 +1082,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield break; case wakeup_by_interrupt: ret = Qundef; + interrupted = true; goto cleanup; } } @@ -1095,7 +1099,11 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield VM_ASSERT(cr->wait.taken_basket.type == basket_type_none); VM_ASSERT(cr->wait.yielded_basket.type == basket_type_none); - RUBY_VM_CHECK_INTS(ec); + if (interrupted) { + rb_vm_check_ints_blocking(ec); + interrupted = false; + goto restart; + } VM_ASSERT(ret != Qundef); return ret; |