Class: EventMachine::Synchrony::AMQP::Queue

Inherits:
AMQP::Queue
  • Object
show all
Defined in:
lib/em-synchrony/amqp.rb

Instance Method Summary collapse

Constructor Details

#initialize(*params) ⇒ Queue

Returns a new instance of Queue.

Raises:


149
150
151
152
153
154
155
# File 'lib/em-synchrony/amqp.rb', line 149

def initialize(*params)
  f = Fiber.current
  super(*params, &EM::Synchrony::AMQP.sync_cb(f))
  queue, declare_ok = Fiber.yield
  raise Error.new unless declare_ok.is_a?(::AMQ::Protocol::Queue::DeclareOk)
  queue
end

Instance Method Details

#asubscribeObject


157
# File 'lib/em-synchrony/amqp.rb', line 157

alias :asubscribe :subscribe

#subscribe(opts = {}, &block) ⇒ Object


158
159
160
161
162
163
# File 'lib/em-synchrony/amqp.rb', line 158

def subscribe(opts = {}, &block)
  Fiber.new do
    asubscribe(opts, &EM::Synchrony::AMQP.sync_cb(Fiber.current))
    loop { block.call(Fiber.yield) }
  end.resume
end