Sha256: 90ba9b8dcce2445638a842f0bafa84e1b12ef129a33a190ddf40705842bfd94e
Contents?: true
Size: 933 Bytes
Versions: 5
Compression:
Stored size: 933 Bytes
Contents
# frozen_string_literal: true module DatadogBackup module ThreadPool 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 ) 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 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 end end
Version data entries
5 entries across 5 versions & 1 rubygems