Class: Garcon::FixedThreadPool
- Inherits:
-
ThreadPoolExecutor
- Object
- ThreadPoolExecutor
- Garcon::FixedThreadPool
- Defined in:
- lib/garcon/task/thread_pool/fixed.rb
Constant Summary
Constants inherited from ThreadPoolExecutor
ThreadPoolExecutor::DEFAULT_MAX_POOL_SIZE, ThreadPoolExecutor::DEFAULT_MAX_QUEUE_SIZE, ThreadPoolExecutor::DEFAULT_MIN_POOL_SIZE, ThreadPoolExecutor::DEFAULT_THREAD_IDLETIMEOUT
Constants included from RubyExecutor
Instance Attribute Summary
Attributes inherited from ThreadPoolExecutor
#completed_task_count, #idletime, #largest_length, #max_length, #max_queue, #min_length, #scheduled_task_count
Attributes included from Executor
Instance Method Summary collapse
-
#initialize(num_threads, opts = {}) ⇒ FixedThreadPool
constructor
Create a new thread pool.
Methods inherited from ThreadPoolExecutor
#can_overflow?, #length, #queue_length, #remaining_capacity, #status
Methods included from RubyExecutor
#<<, #kill, #post, #running?, #shutdown, #shutdown?, #shuttingdown?, #wait_for_termination
Methods included from Executor
#auto_terminate?, #can_overflow?, #serialized?
Constructor Details
#initialize(num_threads, opts = {}) ⇒ FixedThreadPool
Create a new thread pool.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/garcon/task/thread_pool/fixed.rb', line 42 def initialize(num_threads, opts = {}) fallback = opts.fetch(:fallback, :abort) if num_threads < 1 raise ArgumentError, 'number of threads must be greater than zero' elsif !FALLBACK_POLICY.include?(fallback) raise ArgumentError, "#{fallback} is not a valid fallback policy" end opts = opts.merge( min_threads: num_threads, max_threads: num_threads, fallback: fallback, max_queue: DEFAULT_MAX_QUEUE_SIZE, idletime: DEFAULT_THREAD_IDLETIMEOUT) super(opts) end |