Class: Farce::Strict::Lazy

Inherits:
Abstract::Lazy show all
Includes:
Farce::Shareable::Tracked
Defined in:
lib/farce/strict/lazy.rb

Overview

A shareable lazy value that retains its shareable result directly. The factory runs once, even when threads or Ractors access it concurrently. A failed factory or an unshareable result can be retried on the next access.

Examples:

Compute one shared snapshot

lazy = Farce::Strict::Lazy.new { [:ready].freeze }
lazy.value # => [:ready]

Instance Method Summary collapse

Methods included from Farce::Shareable

#initialize, #ractor_shareable?

Methods inherited from Abstract::Lazy

#initialize, #value

Methods included from Abstract::Value

#blank?, #unwrap, #value

Methods included from Internal::Copyable

#duplicable?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Farce::Abstract::Lazy

Instance Method Details

#freeze ⇒ self

Resolve and freeze the slot without freezing the result.

Returns:

  • (self)


19
20
21
22
23
# File 'lib/farce/strict/lazy.rb', line 19

def freeze
  value
  internal_atom.freeze
  super
end