Class: ThreadedEnum::Yielder

Inherits:
Object
  • Object
show all
Defined in:
lib/dream-ops/utils/threaded_enum.rb

Overview

ThreadedEnum helper class

Instance Method Summary collapse

Constructor Details

#initialize(queue, gate, condition) ⇒ Yielder

Returns a new instance of Yielder.



18
19
20
21
22
# File 'lib/dream-ops/utils/threaded_enum.rb', line 18

def initialize(queue, gate, condition)
  @queue = queue
  @gate = gate
  @condition = condition
end

Instance Method Details

#<<(e) ⇒ Object



24
25
26
27
28
29
# File 'lib/dream-ops/utils/threaded_enum.rb', line 24

def <<(e)
  @queue << e
  @gate.synchronize do
    @condition.wait @gate while @queue.size > 0
  end
end