debian-mirror-gitlab/lib/gitlab/gitaly_client/queue_enumerator.rb

29 lines
431 B
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
module Gitlab
module GitalyClient
class QueueEnumerator
def initialize
@queue = Queue.new
end
def push(elem)
@queue << elem
end
def close
push(:close)
end
def each
return enum_for(:each) unless block_given?
loop do
elem = @queue.pop
break if elem == :close
yield elem
end
end
end
end
end