class EnumeratorQueue

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

A EnumeratorQueue wraps a Queue yielding the items added to it via each_item.

Public Class Methods

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

Public Instance Methods

each_item() { |r| ... } click to toggle source
# File src/ruby/bin/math_server.rb, line 98
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