Sha256: e0a4c699f78547e42de87ca6449391aac8ffd3d4fd328c35ffe6cdaf6622267a

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

begin
  require 'eventmachine'
rescue LoadError
  require 'rubygems'
  require 'eventmachine'
end

if EM::VERSION < '0.12.2'
    
  def EventMachine::run blk=nil, tail=nil, &block
    @tails ||= []
    tail and @tails.unshift(tail)

    if reactor_running?
      (b = blk || block) and b.call # next_tick(b)
    else
      @conns = {}
      @acceptors = {}
      @timers = {}
      begin
        @reactor_running = true
        initialize_event_machine
        (b = blk || block) and add_timer(0, b)
        run_machine
      ensure
        release_machine
        @reactor_running = false
      end

      until @tails.empty?
        @tails.pop.call
      end
    end
  end

  def EventMachine::fork_reactor &block
    Kernel.fork do
      if self.reactor_running?
        self.stop_event_loop
        self.release_machine
        self.instance_variable_set( '@reactor_running', false )
      end
      self.run block
    end
  end

end

require 'ext/emfork'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tmm1-amqp-0.5.9 lib/ext/em.rb