Module: DatadogBackup::ThreadPool
- Defined in:
- lib/datadog_backup/thread_pool.rb
Constant Summary collapse
- TPOOL =
::Concurrent::ThreadPoolExecutor.new( min_threads: [2, Concurrent.processor_count].max, max_threads: [2, Concurrent.processor_count].max * 2, max_queue: [2, Concurrent.processor_count].max * 512, fallback_policy: :abort )
Class Method Summary collapse
Class Method Details
.shutdown(logger) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/datadog_backup/thread_pool.rb', line 21 def self.shutdown(logger) logger.fatal 'Shutdown signal caught. Performing orderly shut down of thread pool. Press Ctrl+C again to forcibly shut down, but be warned, DATA LOSS MAY OCCUR.' TPOOL.shutdown TPOOL.wait_for_termination rescue SystemExit, Interrupt logger.fatal 'OK Nuking, DATA LOSS MAY OCCUR.' TPOOL.kill end |
.watcher(logger) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/datadog_backup/thread_pool.rb', line 12 def self.watcher(logger) Thread.new(TPOOL) do |pool| while pool.queue_length > 0 sleep 2 logger.info("#{pool.queue_length} tasks remaining for execution.") end end end |