Sha256: 53bb463c62a7377f7e4b841ab4272a19b8b4f79c73fb21aa637350f78b5d5e54
Contents?: true
Size: 1.04 KB
Versions: 41
Compression:
Stored size: 1.04 KB
Contents
if RUBY_PLATFORM == 'java' require 'concurrent/executor/java_thread_pool_executor' module Concurrent # @!macro cached_thread_pool class JavaCachedThreadPool < JavaThreadPoolExecutor # Create a new thread pool. # # @param [Hash] opts the options defining pool behavior. # @option opts [Symbol] :overflow_policy (`:abort`) the overflow policy # # @raise [ArgumentError] if `overflow_policy` is not a known policy # # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool-- def initialize(opts = {}) @overflow_policy = opts.fetch(:overflow_policy, :abort) @max_queue = 0 raise ArgumentError.new("#{@overflow_policy} is not a valid overflow policy") unless OVERFLOW_POLICIES.keys.include?(@overflow_policy) @executor = java.util.concurrent.Executors.newCachedThreadPool @executor.setRejectedExecutionHandler(OVERFLOW_POLICIES[@overflow_policy].new) set_shutdown_hook end end end end
Version data entries
41 entries across 41 versions & 1 rubygems