JezK
Edit File: cdesc-ThreadPoolExecutor.ri
U:RDoc::NormalClass[iI"ThreadPoolExecutor:EFI"#Concurrent::ThreadPoolExecutor;FI"%ThreadPoolExecutorImplementation;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"*@!macro [attach] thread_pool_executor;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[%I"LAn abstraction composed of one or more threads and a task queue. Tasks ;TI"R(blocks or `proc` objects) are submitted to the pool and added to the queue. ;TI"LThe threads in the pool remove the tasks and execute them in the order ;TI"they were received. ;TI" ;TI"NA `ThreadPoolExecutor` will automatically adjust the pool size according ;TI"Nto the bounds set by `min-threads` and `max-threads`. When a new task is ;TI"Nsubmitted and fewer than `min-threads` threads are running, a new thread ;TI"Nis created to handle the request, even if other worker threads are idle. ;TI"NIf there are more than `min-threads` but less than `max-threads` threads ;TI"Frunning, a new thread will be created only if the queue is full. ;TI" ;TI"OThreads that are idle for too long will be garbage collected, down to the ;TI"[configured minimum options. Should a thread crash it, too, will be garbage collected. ;TI" ;TI"L`ThreadPoolExecutor` is based on the Java class of the same name. From ;TI"&the official Java documentation; ;TI" ;TI"I> Thread pools address two different problems: they usually provide ;TI"P> improved performance when executing large numbers of asynchronous tasks, ;TI"M> due to reduced per-task invocation overhead, and they provide a means ;TI"K> of bounding and managing the resources, including threads, consumed ;TI"J> when executing a collection of tasks. Each ThreadPoolExecutor also ;TI"O> maintains some basic statistics, such as the number of completed tasks. ;TI"> ;TI"N> To be useful across a wide range of contexts, this class provides many ;TI"O> adjustable parameters and extensibility hooks. However, programmers are ;TI"B> urged to use the more convenient Executors factory methods ;TI"V> [CachedThreadPool] (unbounded thread pool, with automatic thread reclamation), ;TI"U> [FixedThreadPool] (fixed size thread pool) and [SingleThreadExecutor] (single ;TI"P> background thread), that preconfigure settings for the most common usage ;TI"> scenarios. ;T:@format0o; ;[I" @!macro thread_pool_options;T@o; ;[I",@!macro thread_pool_executor_public_api;T: @fileI"4lib/concurrent/executor/thread_pool_executor.rb;T:0@omit_headings_from_table_of_contents_below0; 0;0[ [ [ [[I" class;T[[:public[ [:protected[ [:private[ [I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0;0[@:I"Concurrent;FcRDoc::NormalModule