Class: Farce::Local::Lazy
- Inherits:
-
Abstract::Lazy
- Object
- Abstract::Lazy
- Farce::Local::Lazy
- Includes:
- Scoped, Shareable::Unfreezable
- Defined in:
- lib/farce/local/lazy.rb
Overview
A shareable lazy value computed once per scope. Results may be mutable.
Instance Attribute Summary
Attributes included from Scoped
Instance Method Summary collapse
-
#initialize(factory = nil, scope: :ractor) ⇒ Lazy
constructor
Valid scopes are: *
:ractor- The value is shared by all threads within the same Ractor.
Methods included from Shareable
Methods inherited from Abstract::Lazy
Methods included from Abstract::Value
Methods included from Internal::Copyable
Constructor Details
#initialize(factory, scope: :ractor) ⇒ Lazy #initialize(scope: :ractor, self: nil) { ... } ⇒ Lazy
Valid scopes are:
:ractor- The value is shared by all threads within the same Ractor.:thread_group- The value is shared by all threads within the same thread group.:thread- The value is shared by all fibers within the same thread.:fiber_storage- The value is shared by all fibers using the same storage. Unless explicitly specified, storage is inherited from the parent fiber for blocking fibers, but not for non-blocking fibers (such as those created by Scheduler#schedule).:fiber- Each fiber has its own independent value.
23 24 25 26 27 |
# File 'lib/farce/local/lazy.rb', line 23 def initialize(factory = nil, scope: :ractor, **, &) @factory = prepare_factory(factory, **, &) @state_key = Object.new.freeze super(scope:) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Farce::Abstract::Lazy