From a4421bd73c286253311c2cdf8c78ed258f8cff44 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 24 Feb 2023 18:46:17 +0900 Subject: Rewrite Ractor synchronization mechanism This patch rewrites Ractor synchronization mechanism, send/receive and take/yield. * API * Ractor::Selector is introduced for lightweight waiting for many ractors. * Data structure * remove `struct rb_ractor_waiting_list` and use `struct rb_ractor_queue takers_queue` to manage takers. * remove `rb_ractor_t::yield_atexit` and use `rb_ractor_t::sync::will_basket::type` to check the will. * add `rb_ractor_basket::p.take` to represent a taking ractor. * Synchronization protocol * For the Ractor local GC, `take` can not make a copy object directly so ask to generate the copy from the yielding ractor. * The following steps shows what `r1.take` does on `r0`. * step1: (r0) register `r0` into `r1`'s takers. * step2: (r0) check `r1`'s status and wakeup r0 if `r1` is waiting for yielding a value. * step3: (r0) sleep until `r1` wakes up `r0`. * The following steps shows what `Ractor.yield(v)` on `r1`. * step1: (r1) check first takers of `r1` and if there is (`r0`), make a copy object of `v` and pass it to `r0` and wakes up `r0`. * step2: (r1) if there is no taker ractors, sleep until another ractor try to take. --- common.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'common.mk') diff --git a/common.mk b/common.mk index 1b9f3358e2..2dab75f39b 100644 --- a/common.mk +++ b/common.mk @@ -11525,6 +11525,7 @@ ractor.$(OBJEXT): {$(VPATH)}constant.h ractor.$(OBJEXT): {$(VPATH)}debug_counter.h ractor.$(OBJEXT): {$(VPATH)}defines.h ractor.$(OBJEXT): {$(VPATH)}encoding.h +ractor.$(OBJEXT): {$(VPATH)}eval_intern.h ractor.$(OBJEXT): {$(VPATH)}id.h ractor.$(OBJEXT): {$(VPATH)}id_table.h ractor.$(OBJEXT): {$(VPATH)}intern.h -- cgit v1.2.3