Class: InThreads::Filler::Extractor
- Inherits:
-
Object
- Object
- InThreads::Filler::Extractor
- Includes:
- Enumerable
- Defined in:
- lib/in_threads/filler.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(filler) ⇒ Extractor
constructor
A new instance of Extractor.
- #push(o) ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(filler) ⇒ Extractor
Returns a new instance of Extractor.
8 9 10 11 |
# File 'lib/in_threads/filler.rb', line 8 def initialize(filler) @filler = filler @queue = [] end |
Instance Method Details
#each ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/in_threads/filler.rb', line 17 def each begin loop do while @filler.synchronize{ @queue.empty? } @filler.run end yield @filler.synchronize{ @queue.shift } end rescue ThreadError => e end nil # non reusable end |
#push(o) ⇒ Object
13 14 15 |
# File 'lib/in_threads/filler.rb', line 13 def push(o) @queue.push(o) end |