summaryrefslogtreecommitdiff
path: root/test/prism/ractor_test.rb
AgeCommit message (Collapse)Author
2025-11-08[ruby/prism] Rename Ruby 3.5 to Ruby 4.0Earlopain
See https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523 It leaves the old variant around. RuboCop for examples accesses `Prism::Translation::Parser35` to test against ruby-head. For now I left these simply as an alias https://github.com/ruby/prism/commit/d0a823f045
2025-08-05[ruby/prism] Handle new ractor stuffKevin Newton
https://github.com/ruby/prism/commit/f5ded5104d
2025-05-31`Ractor::Port`Koichi Sasada
* Added `Ractor::Port` * `Ractor::Port#receive` (support multi-threads) * `Rcator::Port#close` * `Ractor::Port#closed?` * Added some methods * `Ractor#join` * `Ractor#value` * `Ractor#monitor` * `Ractor#unmonitor` * Removed some methods * `Ractor#take` * `Ractor.yield` * Change the spec * `Racotr.select` You can wait for multiple sequences of messages with `Ractor::Port`. ```ruby ports = 3.times.map{ Ractor::Port.new } ports.map.with_index do |port, ri| Ractor.new port,ri do |port, ri| 3.times{|i| port << "r#{ri}-#{i}"} end end p ports.each{|port| pp 3.times.map{port.receive}} ``` In this example, we use 3 ports, and 3 Ractors send messages to them respectively. We can receive a series of messages from each port. You can use `Ractor#value` to get the last value of a Ractor's block: ```ruby result = Ractor.new do heavy_task() end.value ``` You can wait for the termination of a Ractor with `Ractor#join` like this: ```ruby Ractor.new do some_task() end.join ``` `#value` and `#join` are similar to `Thread#value` and `Thread#join`. To implement `#join`, `Ractor#monitor` (and `Ractor#unmonitor`) is introduced. This commit changes `Ractor.select()` method. It now only accepts ports or Ractors, and returns when a port receives a message or a Ractor terminates. We removes `Ractor.yield` and `Ractor#take` because: * `Ractor::Port` supports most of similar use cases in a simpler manner. * Removing them significantly simplifies the code. We also change the internal thread scheduler code (thread_pthread.c): * During barrier synchronization, we keep the `ractor_sched` lock to avoid deadlocks. This lock is released by `rb_ractor_sched_barrier_end()` which is called at the end of operations that require the barrier. * fix potential deadlock issues by checking interrupts just before setting UBF. https://bugs.ruby-lang.org/issues/21262 Notes: Merged: https://github.com/ruby/ruby/pull/13445
2025-03-20[ruby/prism] Fix fork check in ractor_test.rbBenoit Daloze
https://github.com/ruby/prism/commit/0073266cad
2025-03-20[ruby/prism] Update ractor_test.rb per reviewKevin Newton
https://github.com/ruby/prism/commit/fd96a6821f Notes: Merged: https://github.com/ruby/ruby/pull/12958
2025-03-20Close reader pipesNobuyoshi Nakada
2025-03-19[ruby/prism] Mark Prism as ractor-safeKevin Newton
https://github.com/ruby/prism/commit/c02429765b
2025-03-12[ruby/prism] Revert "Mark extension as Ractor-safe"Kevin Newton
https://github.com/ruby/prism/commit/56eaf53732
2025-03-12[ruby/prism] Mark extension as Ractor-safeKevin Newton
https://github.com/ruby/prism/commit/10e5431b38