Class: InThreads::Filler
- Inherits:
-
Object
- Object
- InThreads::Filler
- Defined in:
- lib/in_threads/filler.rb
Defined Under Namespace
Classes: Extractor
Instance Attribute Summary collapse
-
#extractors ⇒ Object
readonly
Returns the value of attribute extractors.
Instance Method Summary collapse
-
#initialize(enum, extractor_count) ⇒ Filler
constructor
A new instance of Filler.
- #run ⇒ Object
- #synchronize(&block) ⇒ Object
Constructor Details
#initialize(enum, extractor_count) ⇒ Filler
Returns a new instance of Filler.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/in_threads/filler.rb', line 32 def initialize(enum, extractor_count) @extractors = Array.new(extractor_count){ Extractor.new(self) } @mutex = Mutex.new @filler = Thread.new do enum.each do |o| synchronize do @extractors.each do |extractor| extractor.push(o) end end end end end |
Instance Attribute Details
#extractors ⇒ Object (readonly)
Returns the value of attribute extractors.
31 32 33 |
# File 'lib/in_threads/filler.rb', line 31 def extractors @extractors end |
Instance Method Details
#run ⇒ Object
46 47 48 |
# File 'lib/in_threads/filler.rb', line 46 def run @filler.run end |
#synchronize(&block) ⇒ Object
50 51 52 |
# File 'lib/in_threads/filler.rb', line 50 def synchronize(&block) @mutex.synchronize(&block) end |