Class: ThreadedEnum::Yielder
- Inherits:
-
Object
- Object
- ThreadedEnum::Yielder
- Defined in:
- lib/dream-ops/utils/threaded_enum.rb
Overview
ThreadedEnum helper class
Instance Method Summary collapse
- #<<(e) ⇒ Object
-
#initialize(queue, gate, condition) ⇒ Yielder
constructor
A new instance of Yielder.
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 |