Class: Airflow::Executors::ThreadPoolExecutor
- Inherits:
-
Object
- Object
- Airflow::Executors::ThreadPoolExecutor
- Includes:
- Utils::Logger
- Defined in:
- lib/async_flow/executors.rb
Overview
TODO: Replace with ruby-concurrent TODO: min, masx threads TODO: queue size
Instance Method Summary collapse
-
#initialize(size) ⇒ ThreadPoolExecutor
constructor
A new instance of ThreadPoolExecutor.
- #post(*args, &block) ⇒ Object
- #shutdown ⇒ Object
Methods included from Utils::Logger
Constructor Details
#initialize(size) ⇒ ThreadPoolExecutor
Returns a new instance of ThreadPoolExecutor.
11 12 13 14 15 16 17 18 |
# File 'lib/async_flow/executors.rb', line 11 def initialize(size) @jobs = Queue.new @pool = Array.new(size) do Thread.new do poll end end end |
Instance Method Details
#post(*args, &block) ⇒ Object
20 21 22 23 |
# File 'lib/async_flow/executors.rb', line 20 def post(*args, &block) # assert! jobs << [block, args] end |
#shutdown ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/async_flow/executors.rb', line 25 def shutdown logger.info "shutting down executor" pool.size.times do post { throw :exit } end pool.each(&:join) logger.info "executor shut down" end |