Module: EventMachine

Defined in:
lib/em-synchrony.rb,
lib/em-synchrony/thread.rb,
lib/em-synchrony/em-http.rb,
lib/em-synchrony/em-multi.rb,
lib/em-synchrony/em-redis.rb,
lib/em-synchrony/iterator.rb,
lib/em-synchrony/tcpsocket.rb,
lib/em-synchrony/em-mysqlplus.rb,
lib/em-synchrony/connection_pool.rb

Defined Under Namespace

Modules: Protocols, Synchrony Classes: HttpRequest, MySQL

Class Method Summary collapse

Class Method Details

.synchrony(blk = nil, tail = nil, &block) ⇒ Object

A convenience method for wrapping EM.run body within a Ruby Fiber such that async operations can be transparently paused and resumed based on IO scheduling.



22
23
24
25
26
27
# File 'lib/em-synchrony.rb', line 22

def self.synchrony(blk=nil, tail=nil, &block)
  blk ||= block
  context = Proc.new { Fiber.new { blk.call }.resume }

  self.run(context, tail)
end