diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-02-24 18:46:17 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-03-02 14:31:54 +0900 |
commit | a4421bd73c286253311c2cdf8c78ed258f8cff44 (patch) | |
tree | 3ebec079d5ed19429148726e2f5e60597d1df988 /vm_backtrace.c | |
parent | 1abec43b5d3290ef2229ceb64014ed91410a6381 (diff) | |
download | ruby-a4421bd73c286253311c2cdf8c78ed258f8cff44.tar.gz |
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.
Diffstat (limited to 'vm_backtrace.c')
0 files changed, 0 insertions, 0 deletions