Module: Kernel::Extensions

Defined in:
lib/timeout/extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



28
29
30
31
32
33
# File 'lib/timeout/extensions.rb', line 28

def self.included(mod)
  mod.class_eval do
    alias_method :sleep_without_handler, :sleep
    alias_method :sleep, :sleep_with_handler
  end
end

Instance Method Details

#sleep_with_handler(*args) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/timeout/extensions.rb', line 35

def sleep_with_handler(*args)
  if sleep_handler = Thread.current.sleep_handler
    sleep_handler.call(*args)
  else
    sleep_without_handler(*args)
  end
end