Class: EnumeratorQueue

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_server.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(sentinel) ⇒ EnumeratorQueue

Returns a new instance of EnumeratorQueue.



78
79
80
81
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/src/ruby/bin/math_server.rb', line 78

def initialize(sentinel)
  @q = Queue.new
  @sentinel = sentinel
end

Instance Method Details

#each_itemObject



83
84
85
86
87
88
89
90
91
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/grpc-1.50.0-x86_64-linux/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