Arachni::RPC::EM

Provides some convenient methods for EventMachine's Reactor.

@author Tasos "Zapotek" Laskos <tasos.laskos@gmail.com>

Constants

VERSION

Public Instance Methods

block() click to toggle source

Blocks until the Reactor stops running

# File lib/arachni/rpc/em/em.rb, line 36
def block
    # beware of deadlocks, we can't join our own thread
    ::EM.reactor_thread.join if ::EM.reactor_thread && !::EM::reactor_thread?
end
ensure_em_running() click to toggle source

Puts the Reactor in its own thread and runs it.

# File lib/arachni/rpc/em/em.rb, line 42
def ensure_em_running
    if !::EM::reactor_running?

        Thread.new do
            ::EM.run do
                ::EM.error_handler do |e|
                    $stderr.puts "Exception raised during event loop: " +
                    "#{e.message} (#{e.class})\n#{(e.backtrace ||
                        [])[0..5].join("\n")}"
                end
            end
        end

        sleep 0.1 while !::EM.reactor_running?
    end
end
schedule( &block ) click to toggle source

@note Will make sure EM is running first.

@param [Block] block Block to be run in the EM reactor.

# File lib/arachni/rpc/em/em.rb, line 30
def schedule( &block )
    ensure_em_running
    ::EM.schedule( &block )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.