Module: EventMachine

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

Overview

require “em-synchrony/iterator” # iterators are not release in EM yet

Defined Under Namespace

Modules: 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.



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

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

  self.run(context, tail)
end