Module: Arachni::RPC::EM
- Extended by:
- EM
- Included in:
- EM
- Defined in:
- lib/arachni/rpc/em/em.rb,
lib/arachni/rpc/em/client.rb,
lib/arachni/rpc/em/server.rb,
lib/arachni/rpc/em/version.rb,
lib/arachni/rpc/em/protocol.rb,
lib/arachni/rpc/em/connection_utilities.rb,
lib/arachni/rpc/em/ssl.rb
Overview
Provides some convenient methods for EventMachine’s Reactor.
@author: Tasos “Zapotek” Laskos <[email protected]>
Defined Under Namespace
Modules: ConnectionUtilities, Protocol, SSL, Synchrony Classes: Client, Server
Constant Summary collapse
- VERSION =
'0.1.3'
Instance Method Summary collapse
-
#block ⇒ Object
Blocks until the Reactor stops running.
-
#ensure_em_running ⇒ Object
Puts the Reactor in its own thread and runs it.
-
#schedule(&block) ⇒ Object
Schedules a block to be run in the EM reactor.
Instance Method Details
#block ⇒ Object
Blocks until the Reactor stops running
40 41 42 43 |
# File 'lib/arachni/rpc/em/em.rb', line 40 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 ⇒ Object
Puts the Reactor in its own thread and runs it.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/arachni/rpc/em/em.rb', line 48 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.} (#{e.class})\n#{(e.backtrace || [])[0..5].join("\n")}" end end end sleep 0.1 while !::EM.reactor_running? end end |
#schedule(&block) ⇒ Object
Schedules a block to be run in the EM reactor.
32 33 34 35 |
# File 'lib/arachni/rpc/em/em.rb', line 32 def schedule( &block ) ensure_em_running ::EM.schedule( &block ) end |