Module: ActiveSupport::ForkTracker
Do not use. This module is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Defined in: | activesupport/lib/active_support/fork_tracker.rb |
Class Method Summary
- .after_fork(&block)
- .after_fork_callback (also: .check!)
-
.check!
Alias for .after_fork_callback.
- .hook!
- .unregister(callback)
Class Method Details
.after_fork(&block)
[ GitHub ]# File 'activesupport/lib/active_support/fork_tracker.rb', line 67
def after_fork(&block) @callbacks << block block end
.after_fork_callback Also known as: .check!
[ GitHub ]# File 'activesupport/lib/active_support/fork_tracker.rb', line 40
def after_fork_callback new_pid = Process.pid if @pid != new_pid @callbacks.each(&:call) @pid = new_pid end end
.check!
Alias for .after_fork_callback.
# File 'activesupport/lib/active_support/fork_tracker.rb', line 49
def check! # We trust the `_fork` callback end
.hook!
[ GitHub ]# File 'activesupport/lib/active_support/fork_tracker.rb', line 56
def hook! if Process.respond_to?(:_fork) # Ruby 3.1+ ::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)
[ GitHub ]# File 'activesupport/lib/active_support/fork_tracker.rb', line 72
def unregister(callback) @callbacks.delete(callback) end