Sha256: 8c6ab46be24ca74656f5cafd5172928470a902b16f076236c973f7a5c4a56e42
Contents?: true
Size: 1002 Bytes
Versions: 30
Compression:
Stored size: 1002 Bytes
Contents
require "march_hare/juc" module MarchHare # A slighly more Ruby developer-friendly way of instantiating various # JDK executors (thread pools). class ThreadPools # Returns a new thread pool (JDK executor) of a fixed size. # # @return A thread pool (JDK executor) def self.fixed_of_size(n) raise ArgumentError.new("n must be a positive integer!") unless Integer === n raise ArgumentError.new("n must be a positive integer!") unless n > 0 JavaConcurrent::Executors.new_fixed_thread_pool(n) end # Returns a new thread pool (JDK executor) of a fixed size of 1. # # @return A thread pool (JDK executor) def self.single_threaded JavaConcurrent::Executors.new_single_thread_executor end # Returns a new thread pool (JDK executor) that will create new # threads as needed. # # @return A thread pool (JDK executor) def self.dynamically_growing JavaConcurrent::Executors.new_cached_thread_pool end end end
Version data entries
30 entries across 30 versions & 1 rubygems