@@ -16,25 +16,35 @@ module Concurrent
1616
1717 # @!macro [attach] single_thread_executor
1818 #
19- # A thread pool with a set number of threads. The number of threads in the pool
20- # is set on construction and remains constant. When all threads are busy new
21- # tasks `#post` to the thread pool are enqueued until a thread becomes available.
22- # Should a thread crash for any reason the thread will immediately be removed
23- # from the pool and replaced.
19+ # A thread pool with a single thread an unlimited queue. Should the thread
20+ # die for any reason it will be removed and replaced, thus ensuring that
21+ # the executor will always remain viable and available to process jobs.
2422 #
25- # The API and behavior of this class are based on Java's `SingleThreadExecutor`
23+ # A common pattern for background processing is to create a single thread
24+ # on which an infinite loop is run. The thread's loop blocks on an input
25+ # source (perhaps blocking I/O or a queue) and processes each input as it
26+ # is received. This pattern has several issues. The thread itself is highly
27+ # susceptible to errors during processing. Also, the thread itself must be
28+ # constantly monitored and restarted should it die. `SingleThreadExecutor`
29+ # encapsulates all these bahaviors. The task processor is highly resilient
30+ # to errors from within tasks. Also, should the thread die it will
31+ # automatically be restarted.
32+ #
33+ # The API and behavior of this class are based on Java's `SingleThreadExecutor`.
2634 #
27- # @!macro thread_pool_options
2835 # @!macro abstract_executor_service_public_api
2936 class SingleThreadExecutor < SingleThreadExecutorImplementation
3037
3138 # @!macro [new] single_thread_executor_method_initialize
3239 #
3340 # Create a new thread pool.
3441 #
35- # @option opts [Symbol] :fallback_policy (:discard) the policy for
36- # handling new tasks that are received when the queue size has
37- # reached `max_queue` or after the executor has shut down
42+ # @option opts [Symbol] :fallback_policy (:discard) the policy for handling new
43+ # tasks that are received when the queue size has reached
44+ # `max_queue` or the executor has shut down
45+ #
46+ # @raise [ArgumentError] if `:fallback_policy` is not one of the values specified
47+ # in `FALLBACK_POLICIES`
3848 #
3949 # @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
4050 # @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
0 commit comments