Class: Couchbase::Async::Queue
- Inherits:
-
Object
- Object
- Couchbase::Async::Queue
- Defined in:
- lib/couchbase/async/queue.rb
Instance Method Summary collapse
- #add_future(future, options, &block) ⇒ Object
-
#initialize(bucket) ⇒ Queue
constructor
A new instance of Queue.
- #join ⇒ Object
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, , &block) @futures << [ future, , block ] end |
#join ⇒ Object
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, , callback = future future.get result = Couchbase::Result.new({ bucket: @bucket, future: future }.merge()) callback.call(result) unless callback.nil? end end end |