Sha256: a32f42c6bfa05353c69c73803310f59d950162d5e6b971ad798b5ad5745b3855

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

begin
  require 'eventmachine/sync-defer'
rescue LoadError
end

begin
  require 'cool.io/sync-defer'
rescue LoadError
end

module SyncDefer
  module_function
  def defer *args, &block
    if Object.const_defined?(:EventMachine) && EventMachine.reactor_running?
      EventMachine::SyncDefer.defer(*args, &block)
    elsif Object.const_defined?(:Coolio) &&
          Coolio::Loop.default.has_active_watchers?
      Coolio::SyncDefer.defer(*args, &block)
    else
      $stderr.puts("SyncDefer: WARN: No reactor found. " \
                   "Only cool.io and eventmachine are supported.")
      $stderr.puts("           Called from: #{caller.last(5).inspect}")
      args << block if block_given?
      args.map(&:call)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sync-defer-0.9.3 lib/sync-defer.rb