lib/asynchro/test_helper.rb
# Wraps a given block in an EventMachine run loop. Because this loop will
# monopolize the thread, a new thread is created to execute the supplied
# block. Exceptions are trapped from both the supplied block and the
# engine and raised accordingly.
Wraps a given block in an EventMachine run loop. Because this loop will
monopolize the thread, a new thread is created to execute the supplied
block. Exceptions are trapped from both the supplied block and the
engine and raised accordingly.
Wraps a given block in an EventMachine run loop . Because this loop will monopolize the thread a new thread is created to execute the supplied block . Exceptions are trapped from both the supplied block and the engine and raised accordingly .
def eventmachine
    exception = nil
    Thread.new do
      Thread.abort_on_exception = true
      begin
        EventMachine.run do
          Thread.new do
            begin
              yield
            rescue Object => exception
            ensure
              begin
                EventMachine.stop_event_loop
              rescue Object
              end
            end
          end
        end
      rescue Object => exception
      end
    end.join
    if (exception)
      raise exception
    end
  end
def eventmachine exception = nil Thread . new do Thread . abort_on_exception = true begin EventMachine . run do Thread . new do begin yield rescue Object => exception ensure begin EventMachine . stop_event_loop rescue Object end end end end rescue Object => exception end end . join if ( exception ) raise exception end end
Wraps a given block in an EventMachine run loop.
Wraps a given block in an EventMachine run loop .
# Create a thread for the engine to run on # Execute the test code in a separate thread to avoid blocking # the EventMachine loop. # Shutting down may trigger an exception from time to time # if the engine itself has failed.