module Kernel

Monkey-patch

Attributes

em_synchrony_sleep_hook[RW]

Public Instance Methods

orig_sleep(*args)
Alias for: sleep
silence_warnings() { || ... } click to toggle source
# File lib/em-synchrony/core_ext.rb, line 3
def silence_warnings
  old_verbose, $VERBOSE = $VERBOSE, nil
  yield
ensure
  $VERBOSE = old_verbose
end
sleep(*args) click to toggle source

Monkey-patch

# File lib/em-synchrony/kernel.rb, line 13
def sleep(*args)
  if Kernel.em_synchrony_sleep_hook &&
     EM.reactor_thread? &&
     !Thread.current[:em_synchrony_sleep_hook_called]
    begin
      Thread.current[:em_synchrony_sleep_hook_called] = true
      Kernel.em_synchrony_sleep_hook.call(args[0])
    ensure
      Thread.current[:em_synchrony_sleep_hook_called] = false
    end
  else
    orig_sleep(*args)
  end
end
Also aliased as: orig_sleep