class Garcon::FixedThreadPool
Public Class Methods
new(num_threads, opts = {})
click to toggle source
Create a new thread pool.
@param [Integer] num_threads
The number of threads to allocate.
@param [Hash] opts
The options defining pool behavior.
@option opts [Symbol] :fallback (‘:abort`)
The fallback policy
@raise [ArgumentError] if ‘num_threads` is less than or equal to zero
@raise [ArgumentError] if ‘fallback` is not a known policy
@api public
Calls superclass method
Garcon::ThreadPoolExecutor::new
# 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