Module: Julewire::Core::Integration::ForkHooks

Defined in:
lib/julewire/core/integration/fork_hooks.rb

Class Method Summary collapse

Class Method Details

.after_fork!Object



28
29
30
31
# File 'lib/julewire/core/integration/fork_hooks.rb', line 28

def after_fork!
  @mutex = Mutex.new
  nil
end

.register(integration, component:, &callback) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
# File 'lib/julewire/core/integration/fork_hooks.rb', line 14

def register(integration, component:, &callback)
  raise ArgumentError, "block required" unless callback

  name = integration_name(integration)
  component = component.to_sym
  register_entry(name, component, callback)
end

.reset!Object



33
34
35
36
# File 'lib/julewire/core/integration/fork_hooks.rb', line 33

def reset!
  mutex.synchronize { entries.clear }
  nil
end

.runObject



22
23
24
25
26
# File 'lib/julewire/core/integration/fork_hooks.rb', line 22

def run
  snapshot = mutex.synchronize { entries.values }
  snapshot.each { run_entry(it) }
  nil
end