class Google::Cloud::PubSub::Subscriber::EnumeratorQueue

@private

Public Class Methods

new(sentinel = nil) click to toggle source
# File lib/google/cloud/pubsub/subscriber/enumerator_queue.rb, line 22
def initialize sentinel = nil
  @queue    = Queue.new
  @sentinel = sentinel
end

Public Instance Methods

each() { |obj| ... } click to toggle source
# File lib/google/cloud/pubsub/subscriber/enumerator_queue.rb, line 39
def each
  return enum_for :each unless block_given?

  loop do
    obj = @queue.pop
    break if obj.equal? @sentinel
    yield obj
  end
end
push(obj) click to toggle source
# File lib/google/cloud/pubsub/subscriber/enumerator_queue.rb, line 27
def push obj
  @queue.push obj
end
quit_and_dump_queue() click to toggle source
# File lib/google/cloud/pubsub/subscriber/enumerator_queue.rb, line 31
def quit_and_dump_queue
  objs = []
  objs << @queue.pop until @queue.empty?
  # Signal that the enumerator is ready to end
  @queue.push @sentinel
  objs
end