Class: Concurrent::JavaFixedThreadPool
- Inherits:
-
JavaThreadPoolExecutor
- Object
- JavaThreadPoolExecutor
- Concurrent::JavaFixedThreadPool
- Defined in:
- lib/concurrent/executor/java_fixed_thread_pool.rb
Overview
When running on the JVM (JRuby) this class will inherit from JavaFixedThreadPool. On all other platforms it will inherit from RubyFixedThreadPool.
A thread pool with a set number of threads. The number of threads in the pool is set on construction and remains constant. When all threads are busy new tasks #post to the thread pool are enqueued until a thread becomes available. Should a thread crash for any reason the thread will immediately be removed from the pool and replaced.
The API and behavior of this class are based on Java’s FixedThreadPool
Constant Summary
Constants inherited from JavaThreadPoolExecutor
Concurrent::JavaThreadPoolExecutor::DEFAULT_MAX_POOL_SIZE, Concurrent::JavaThreadPoolExecutor::DEFAULT_MAX_QUEUE_SIZE, Concurrent::JavaThreadPoolExecutor::DEFAULT_MIN_POOL_SIZE, Concurrent::JavaThreadPoolExecutor::DEFAULT_THREAD_IDLETIMEOUT
Constants included from JavaExecutor
Concurrent::JavaExecutor::FALLBACK_POLICIES
Instance Attribute Summary
Attributes inherited from JavaThreadPoolExecutor
Attributes included from Executor
Instance Method Summary collapse
-
#initialize(num_threads, opts = {}) ⇒ JavaFixedThreadPool
constructor
Create a new thread pool.
Methods inherited from JavaThreadPoolExecutor
#can_overflow?, #completed_task_count, #idletime, #largest_length, #length, #min_length, #queue_length, #remaining_capacity, #running?, #scheduled_task_count, #status
Methods included from JavaExecutor
#<<, #kill, #post, #running?, #shutdown, #shutdown?, #shuttingdown?, #wait_for_termination
Methods included from Executor
Constructor Details
#initialize(num_threads, opts = {}) ⇒ JavaFixedThreadPool
Create a new thread pool.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/concurrent/executor/java_fixed_thread_pool.rb', line 19 def initialize(num_threads, opts = {}) opts = { min_threads: num_threads, max_threads: num_threads }.merge(opts) super(opts) set_shutdown_hook end |