class Concurrent::RubyThreadPoolExecutor

def initialize(opts = {})

Other tags:
    See: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html -

Raises:
  • (ArgumentError) - if `:overflow_policy` is not one of the values specified
  • (ArgumentError) - if `:min_threads` is less than zero
  • (ArgumentError) - if `:max_threads` is less than one

Options Hash: (**opts)
  • :overflow_policy (Symbol) -- the policy for handling new
  • :max_queue (Integer) -- the maximum
  • :idletime (Integer) -- the maximum
  • :min_threads (Integer) -- the minimum
  • :max_threads (Integer) -- the maximum

Parameters:
  • opts (Hash) -- the options which configure the thread pool
def initialize(opts = {})
  @min_length = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i
  @max_length = opts.fetch(:max_threads, DEFAULT_MAX_POOL_SIZE).to_i
  @idletime = opts.fetch(:idletime, DEFAULT_THREAD_IDLETIMEOUT).to_i
  @max_queue = opts.fetch(:max_queue, DEFAULT_MAX_QUEUE_SIZE).to_i
  @overflow_policy = opts.fetch(:overflow_policy, :abort)
  raise ArgumentError.new('max_threads must be greater than zero') if @max_length <= 0
  raise ArgumentError.new('min_threads cannot be less than zero') if @min_length < 0
  raise ArgumentError.new("#{overflow_policy} is not a valid overflow policy") unless OVERFLOW_POLICIES.include?(@overflow_policy)
  init_executor
  @pool = []
  @queue = Queue.new
  @scheduled_task_count = 0
  @completed_task_count = 0
  @largest_length = 0
  @gc_interval = opts.fetch(:gc_interval, 1).to_i # undocumented
  @last_gc_time = Time.now.to_f - [1.0, (@gc_interval * 2.0)].max
end