diff options
-rw-r--r-- | ractor.c | 10 | ||||
-rw-r--r-- | thread.c | 6 | ||||
-rw-r--r-- | vm_core.h | 1 |
3 files changed, 16 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; @@ -218,6 +218,12 @@ vm_check_ints_blocking(rb_execution_context_t *ec) return rb_threadptr_execute_interrupts(th, 1); } +int +rb_vm_check_ints_blocking(rb_execution_context_t *ec) +{ + return vm_check_ints_blocking(ec); +} + /* * poll() is supported by many OSes, but so far Linux is the only * one we know of that supports using poll() in all places select() @@ -1836,6 +1836,7 @@ void rb_execution_context_update(const rb_execution_context_t *ec); void rb_execution_context_mark(const rb_execution_context_t *ec); void rb_fiber_close(rb_fiber_t *fib); void Init_native_thread(rb_thread_t *th); +int rb_vm_check_ints_blocking(rb_execution_context_t *ec); #define RUBY_VM_CHECK_INTS(ec) rb_vm_check_ints(ec) static inline void |