Class: Rigor::Environment::HktRegistryHolder

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/environment/hkt_registry_holder.rb

Overview

ADR-20 slice 2e — mutable single-slot memoization container for the per-Environment HKT registry. Held by Rigor::Environment so the otherwise-frozen instance can still cache a computed value on first access.

Concurrent #fetch calls from multiple threads against one Environment are NOT serialised here — the LSP single-publish-at-a-time discipline and the Ractor pool’s per-worker Environment shape already prevent cross-thread races. If a future caller introduces a multi-threaded reader path against a shared Environment, the synchronisation belongs at that caller’s seam, not here.

Instance Method Summary collapse

Constructor Details

#initializeHktRegistryHolder

Returns a new instance of HktRegistryHolder.



19
20
21
22
# File 'lib/rigor/environment/hkt_registry_holder.rb', line 19

def initialize
  @loaded = false
  @value = nil
end

Instance Method Details

#fetchObject



24
25
26
27
28
29
30
# File 'lib/rigor/environment/hkt_registry_holder.rb', line 24

def fetch
  return @value if @loaded

  @value = yield
  @loaded = true
  @value
end