Module: ActiveSupport::ForkTracker
- Defined in:
- lib/active_support/fork_tracker.rb
Overview
Defined Under Namespace
Modules: CoreExt, CoreExtPrivate, ModernCoreExt
Class Method Summary
collapse
Class Method Details
.after_fork(&block) ⇒ Object
59
60
61
62
|
# File 'lib/active_support/fork_tracker.rb', line 59
def after_fork(&block)
@callbacks << block
block
end
|
40
41
42
43
44
45
46
|
# File 'lib/active_support/fork_tracker.rb', line 40
def check!
new_pid = Process.pid
if @pid != new_pid
@callbacks.each(&:call)
@pid = new_pid
end
end
|
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/active_support/fork_tracker.rb', line 48
def hook!
if Process.respond_to?(:_fork)
::Process.singleton_class.prepend(ModernCoreExt)
elsif Process.respond_to?(:fork)
::Object.prepend(CoreExtPrivate) if RUBY_VERSION < "3.0"
::Kernel.prepend(CoreExtPrivate)
::Kernel.singleton_class.prepend(CoreExt)
::Process.singleton_class.prepend(CoreExt)
end
end
|
.unregister(callback) ⇒ Object
64
65
66
|
# File 'lib/active_support/fork_tracker.rb', line 64
def unregister(callback)
@callbacks.delete(callback)
end
|