Module: Julewire::Core::LocalStorage

Defined in:
lib/julewire/core/local_storage.rb

Overview

Process/ractor-local storage for facade lookups. The ractor bridge can set the current runtime from inside a child ractor, but the getter side still runs inside core through Julewire.* facade calls.

Class Method Summary collapse

Class Method Details

.context_storeObject



34
35
36
# File 'lib/julewire/core/local_storage.rb', line 34

def context_store
  context_store_value || store_context(ContextStore.new)
end

.reset_context_store!Object



38
39
40
# File 'lib/julewire/core/local_storage.rb', line 38

def reset_context_store!
  store_context(nil)
end

.runtimeObject



20
21
22
23
24
# File 'lib/julewire/core/local_storage.rb', line 20

def runtime
  return ractor_runtime if ractor_local_storage?

  runtime_ref.update { it || Runtime.new }
end

.runtime=(runtime) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/julewire/core/local_storage.rb', line 26

def runtime=(runtime)
  if ractor_local_storage?
    ::Ractor[RUNTIME_KEY] = runtime
  else
    runtime_ref.set(runtime)
  end
end