summaryrefslogtreecommitdiff
path: root/test/json/ractor_test.rb
AgeCommit message (Collapse)Author
2025-11-21[ruby/json] Ractor-shareable JSON::CoderÉtienne Barrié
https://github.com/ruby/json/commit/58d60d6b76
2025-08-27[ruby/json] Silence ractor experimental warningsJean Boussier
https://github.com/ruby/json/commit/e77f610b21
2025-08-18Fix typosDouglas Eichelberger
2025-06-03[ruby/json] Update `JSONInRactorTest` to handle Ruby 3.5 Ractors.Jean Boussier
https://github.com/ruby/json/commit/d42b36963d
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
2024-10-26json_pure: fix ractor compatibilityJean Boussier
This actually never worked, because the test was always testing the ext version from the stdlib, never the pure version nor the current ext version.
2024-10-26Use frozen string literalsÉtienne Barrié
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-16[ruby/json] ractor_test.rb: ignore stderrJean Boussier
When rubygems is double loaded it fails the test. The warning should happen in the first place but this makes the test more resilient. https://github.com/ruby/json/commit/513ddeaeb1
2023-12-05[flori/json] The modern Ruby uses utf-8 encodings by defaultHiroshi SHIBATA
https://github.com/flori/json/commit/11b31210ac
2023-12-01lib/helper only needs on flori/json repoHiroshi SHIBATA
2023-12-01[flori/json] tests/ractor_test.rb: make assert_separately availableLucas Kanashiro
Require tests/lib/helper.rb to avoid: NoMethodError: undefined method `assert_separately' https://github.com/flori/json/commit/a81bcc0328
2023-08-25Use require_relative in JSON testsTakashi Kokubun
to prevent them from conflicting with yarp/test_helper
2020-12-22Prepare to release json-2.5.0Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/3975
2020-12-21[json] Make json Ractor safeKenta Murata