Class: Gitlab::GitalyClient::QueueEnumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/gitaly_client/queue_enumerator.rb

Instance Method Summary collapse

Constructor Details

#initializeQueueEnumerator

Returns a new instance of QueueEnumerator.


6
7
8
# File 'lib/gitlab/gitaly_client/queue_enumerator.rb', line 6

def initialize
  @queue = Queue.new
end

Instance Method Details

#closeObject


14
15
16
# File 'lib/gitlab/gitaly_client/queue_enumerator.rb', line 14

def close
  push(:close)
end

#eachObject


18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/gitaly_client/queue_enumerator.rb', line 18

def each
  return enum_for(:each) unless block_given?

  loop do
    elem = @queue.pop
    break if elem == :close

    yield elem
  end
end

#push(elem) ⇒ Object


10
11
12
# File 'lib/gitlab/gitaly_client/queue_enumerator.rb', line 10

def push(elem)
  @queue << elem
end