Method: NoBrainer::QueryRunner::EMDriver.sync

Defined in:
lib/no_brainer/query_runner/em_driver.rb

.sync(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/no_brainer/query_runner/em_driver.rb', line 15

def self.sync(&block)
  # Similar to em-synchrony's sync.
  f = Fiber.current
  block.call(proc do |val|
    if f == Fiber.current
      return val
    else
      f.resume(val)
    end
  end)
  Fiber.yield
end