Module: ContrastThread

Included in:
Thread
Defined in:
lib/contrast/extension/thread.rb

Overview

Prepending Thread#initialize.

Instance Method Summary collapse

Instance Method Details

#initialize(*args, &block) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/contrast/extension/thread.rb', line 37

def initialize *args, &block
  # Thread.current still references the original(callee) thread that is instantiating this new fiber during
  # initialization.
  Contrast::Components::Scope::MONITOR.synchronize do
    if (current_context = Thread.current[:current_context])
      self[:current_context] = current_context.dup
    end
    Contrast::Components::Scope.sweep_dead_ecs
  end
  super
end