Class: Couchbase::Async::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/async/queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket) ⇒ Queue

Returns a new instance of Queue.



5
6
7
8
# File 'lib/couchbase/async/queue.rb', line 5

def initialize(bucket)
  @bucket  = bucket
  @futures = []
end

Instance Method Details

#add_future(future, options, &block) ⇒ Object



10
11
12
# File 'lib/couchbase/async/queue.rb', line 10

def add_future(future, options, &block)
  @futures << [ future, options, block ]
end

#joinObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/couchbase/async/queue.rb', line 14

def join
  while future = @futures.pop
    begin
      future, options, callback = future
      future.get
      result = Couchbase::Result.new({ bucket: @bucket, future: future }.merge(options))
      callback.call(result) unless callback.nil?
    end
  end
end