Module: ActiveSupport::Ractors
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Autoload
|
|
| Defined in: | activesupport/lib/active_support/ractors.rb, activesupport/lib/active_support/ractors/logger.rb, activesupport/lib/active_support/ractors/logger/device_proxy.rb, activesupport/lib/active_support/ractors/logger/writer.rb |
Overview
Shims for Ractor shareability methods so framework code can call them
unconditionally regardless of the Ruby version.
Class Attribute Summary
-
.main?
readonly
See additional method definition at line 108.
- .unshareable_proc_action rw
Class Method Summary
-
.[](key)
Returns the value stored under
keyin the current Ractor's local storage. -
.[]=(key, value)
Stores
valueunderkeyin the current Ractor's local storage. -
.make_shareable(obj, copy: false)
Makes
objRactor-shareable by delegating toRactor.make_shareable. -
.on_main(obj = nil, &block)
See additional method definition at line 98.
-
.shareable?(obj) ⇒ Boolean
Returns whether
objis Ractor-shareable by delegating toRactor.shareable?. -
.shareable_lambda(self: nil, &block)
Returns a Ractor-shareable lambda by delegating to
Ractor.shareable_lambda. -
.shareable_proc(self: nil, &block)
Returns a Ractor-shareable proc by delegating to
Ractor.shareable_proc. -
.store_if_absent(key, &block)
Returns the value stored under
keyin the current Ractor's local storage, runningblockto compute and store it on first access, by delegating toRactor.store_if_absent. -
.try_make_shareable(obj)
Attempt to make an object shareable.
-
.try_shareable_lambda(receiver, &block)
Attempt to make a lambda shareable, bound to
receiveras itsself. -
.try_shareable_proc(proc = nil, &block)
Attempt to make a proc shareable.
Autoload - Extended
Class Attribute Details
.main? (readonly)
See additional method definition at line 108.
# File 'activesupport/lib/active_support/ractors.rb', line 149
def main? Ractor.main? end
Class Method Details
.[](key)
Returns the value stored under key in the current Ractor's local
storage. Returns nil when nothing has been stored under key yet.
Each Ractor has an isolated local storage, so values set in one Ractor are not visible to any other.
# File 'activesupport/lib/active_support/ractors.rb', line 180
def self.[](key) Ractor.current[key] end
.[]=(key, value)
Stores value under key in the current Ractor's local storage.
The value is only visible to the current Ractor, and other
Ractors have their own independent storage.
# File 'activesupport/lib/active_support/ractors.rb', line 187
def self.[]=(key, value) Ractor.current[key] = value end
.on_main(obj = nil, &block)
See additional method definition at line 98.
# File 'activesupport/lib/active_support/ractors.rb', line 153
def on_main(obj = nil, &block) if Ractor.main? obj.instance_eval(&block) else require "ractor/dispatch" shareable_block = Ractor.shareable_proc(&block) Ractor::Dispatch.main.run { obj.instance_eval(&shareable_block) } end end
.store_if_absent(key, &block)
Returns the value stored under key in the current Ractor's local
storage, running block to compute and store it on first access, by
delegating to Ractor.store_if_absent. Concurrent threads in the
same Ractor initialize the value only once.
See additional method definition at line 196.
# File 'activesupport/lib/active_support/ractors.rb', line 206
def self.store_if_absent(key, &block) Ractor.store_if_absent(key, &block) end