Class: EMJack::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/em-synchrony/em-jack.rb

Instance Method Summary collapse

Instance Method Details

#auseObject


12
# File 'lib/em-synchrony/em-jack.rb', line 12

alias :ause :use

#use(tube, &blk) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/em-synchrony/em-jack.rb', line 13

def use(tube, &blk)
  return if @used_tube == tube

  f = Fiber.current

  # WANT: per command errbacks, would be nice, instead of one global
  # errback  = Proc.new {|r| f.resume(r) }

  on_error {|r| f.resume(r)}

  @used_tube = tube
  @conn.send(:use, tube)

  # WANT: Add conditional on add_deferrable to either accept two procs, or a single block
  #       .. two procs = callback, errback
  add_deferrable { |r| f.resume(r) }

  Fiber.yield
end