Class: Infrastruct::Runner
- Inherits:
-
Object
- Object
- Infrastruct::Runner
- Defined in:
- lib/infrastruct/runner.rb
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(factory) ⇒ Runner
constructor
A new instance of Runner.
- #perform(args) ⇒ Object
Constructor Details
#initialize(factory) ⇒ Runner
Returns a new instance of Runner.
3 4 5 6 7 |
# File 'lib/infrastruct/runner.rb', line 3 def initialize(factory) @factory = factory @results = Array.new @mutex = Mutex.new end |
Instance Method Details
#collect ⇒ Object
16 17 18 19 20 |
# File 'lib/infrastruct/runner.rb', line 16 def collect worker = @factory.new @mutex.synchronize { worker.collect(@results) } end |
#perform(args) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/infrastruct/runner.rb', line 9 def perform(args) worker = @factory.new result = worker.perform(*args) @mutex.synchronize { @results << result } end |