Expand description
Execute tasks on one of possibly several pooled threads.
A thread pool contains a set of previously spawned threads enabling running tasks in parallel without having to spawn up a new thread for each task. The thread pool supports a variety of different configuration options useful for tweaking its exact behavior.
Thread pools address two different porblems: they usually provide improved performance when executing large numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and managing the resources, including threads, consumed when executing a collection of tasks.
To be useful across a wide range of contexts, ThreadPool
provides a number
of adjustable parameters and extensibility hooks. However, programmers are
urged to use the more convenient builder methods,
fixed_size
, and
single_thread
(single
background thread), that preconfigure settings for the most common usage
scenarios. Otherwise, use the following guide when manually configuring and
tuning a ThreadPool
.
Structs§
- Builder
- Thread pool configuration.
- Send
Error - An error returned from the
Sender::send
orSyncSender::send
function on channels. - Sender
- A handle that allows dispatching work to a thread pool.
- Thread
Pool - Execute tasks on one of possibly several pooled threads.
Enums§
- Send
Timeout Error - Possible errors that
send_timeout
could encounter. - TrySend
Error - This enumeration is the list of the possible error outcomes for the
try_send
method.