class EnumeratorQueue

A EnumeratorQueue wraps a Queue to yield the items added to it.

Public Class Methods

new(sentinel) click to toggle source
# File src/ruby/bin/math_server.rb, line 78
def initialize(sentinel)
  @q = Queue.new
  @sentinel = sentinel
end

Public Instance Methods

each() { |msg| ... } click to toggle source
# File src/ruby/spec/generic/client_stub_spec.rb, line 777
def each
  loop do
    msg = @queue.pop
    break if msg.nil?
    yield msg
  end
end
each_item() { |r| ... } click to toggle source
# File src/ruby/bin/math_server.rb, line 83
def each_item
  return enum_for(:each_item) unless block_given?
  loop do
    r = @q.pop
    break if r.equal?(@sentinel)
    fail r if r.is_a? Exception
    yield r
  end
end