Class: Lemans::Runner::Executor
- Inherits:
-
Object
- Object
- Lemans::Runner::Executor
- Defined in:
- lib/lemans/runner/executor.rb
Overview
A default (Threaded) concurrent executor for tasks
Defined Under Namespace
Classes: Results
Instance Method Summary collapse
- #<<(task) ⇒ Object
-
#initialize(concurrency) ⇒ Executor
constructor
A new instance of Executor.
- #shutdown ⇒ Object
- #start ⇒ Object
- #terminate ⇒ Object
Constructor Details
Instance Method Details
#<<(task) ⇒ Object
29 30 31 |
# File 'lib/lemans/runner/executor.rb', line 29 def <<(task) queue << task end |
#shutdown ⇒ Object
40 41 42 43 44 |
# File 'lib/lemans/runner/executor.rb', line 40 def shutdown queue.close pool.each(&:join) raise @abort if @abort end |
#start ⇒ Object
22 23 24 25 26 27 |
# File 'lib/lemans/runner/executor.rb', line 22 def start @pool = Array.new(concurrency) do Thread.new { drain } end results end |
#terminate ⇒ Object
33 34 35 36 37 38 |
# File 'lib/lemans/runner/executor.rb', line 33 def terminate queue.clear queue.close pool.each { it.raise(Shutdown) if it.alive? } pool.each(&:join) end |