summaryrefslogtreecommitdiff
path: root/ractor.h
AgeCommit message (Collapse)Author
2020-10-31Ractor's "will" doesn't need copying.Koichi Sasada
`r = Ractor.new{ expr }` generates the block return value from `expr` and we can get this value by `r.take`. Ractor.yield and Ractor#take passing values by copying on default. However, the block return value (we named it "will" in the code) is not referred from the Ractor because the Ractor is already dead. So we can pass the reference of "will" to another ractor without copying. We can apply same story for the propagated exception. Notes: Merged: https://github.com/ruby/ruby/pull/3724
2020-10-21refactoring rb_ractor_confirm_belonging()Koichi Sasada
rb_ractor_belonging() returns 0 only if it has sharable flag. rb_ractor_confirm_belonging() checks rb_ractor_shareable_p() if the belonging ractor id is different from current ractor id. Notes: Merged: https://github.com/ruby/ruby/pull/3682
2020-10-21Ractor-safe rb_objspace_reachable_objects_fromKoichi Sasada
rb_objspace_reachable_objects_from(obj) is used to traverse all reachable objects from obj. This function modify objspace but it is not ractor-safe (thread-safe). This patch fix the problem. Strategy: (1) call GC mark process during_gc (2) call Ractor-local custom mark func when !during_gc Notes: Merged: https://github.com/ruby/ruby/pull/3680
2020-10-20Some global variables can be accessed from ractorsKoichi Sasada
Some global variables should be used from non-main Ractors. [Bug #17268] ```ruby # ractor-local (derived from created ractor): debug '$DEBUG' => $DEBUG, '$-d' => $-d, # ractor-local (derived from created ractor): verbose '$VERBOSE' => $VERBOSE, '$-w' => $-w, '$-W' => $-W, '$-v' => $-v, # process-local (readonly): other commandline parameters '$-p' => $-p, '$-l' => $-l, '$-a' => $-a, # process-local (readonly): getpid '$$' => $$, # thread local: process result '$?' => $?, # scope local: match '$~' => $~.inspect, '$&' => $&, '$`' => $`, '$\'' => $', '$+' => $+, '$1' => $1, # scope local: last line '$_' => $_, # scope local: last backtrace '$@' => $@, '$!' => $!, # ractor local: stdin, out, err '$stdin' => $stdin.inspect, '$stdout' => $stdout.inspect, '$stderr' => $stderr.inspect, ``` Notes: Merged: https://github.com/ruby/ruby/pull/3670
2020-10-20Use language TLS specifier if it is possible.Koichi Sasada
To access TLS, it is faster to use language TLS specifier instead of using pthread_get/setspecific functions. Original proposal is: Use native thread locals. #3665 Notes: Merged: https://github.com/ruby/ruby/pull/3667
2020-10-12change rb_ractor_queue to ring buffertompng
Notes: Merged: https://github.com/ruby/ruby/pull/3642
2020-10-10Add Ractor#receive and Ractor.receive and use it in all placesBenoit Daloze
* Keep Ractor#recv/Ractor.recv as an alias for now. Notes: Merged: https://github.com/ruby/ruby/pull/3626
2020-09-25Ractor#close_outgoping cancel Ractor.yieldKoichi Sasada
Ractor#close_outgoing should cancel waiting Ractor.yield. However, yield a value by the Ractor's block should not cancel (to recognize terminating Ractor, introduce rb_ractor_t::yield_atexit flag). Notes: Merged: https://github.com/ruby/ruby/pull/3572
2020-09-18show object info to debug purpose.Koichi Sasada
Notes: Merged: https://github.com/ruby/ruby/pull/3548
2020-09-03Introduce Ractor mechanism for parallel executionKoichi Sasada
This commit introduces Ractor mechanism to run Ruby program in parallel. See doc/ractor.md for more details about Ractor. See ticket [Feature #17100] to see the implementation details and discussions. [Feature #17100] This commit does not complete the implementation. You can find many bugs on using Ractor. Also the specification will be changed so that this feature is experimental. You will see a warning when you make the first Ractor with `Ractor.new`. I hope this feature can help programmers from thread-safety issues. Notes: Merged: https://github.com/ruby/ruby/pull/3365