thread_pool/lib.rs
1//! Execute tasks on one of possibly several pooled threads.
2//!
3//! A thread pool contains a set of previously spawned threads enabling running
4//! tasks in parallel without having to spawn up a new thread for each task. The
5//! thread pool supports a variety of different configuration options useful for
6//! tweaking its exact behavior.
7//!
8//! Thread pools address two different porblems: they usually provide improved
9//! performance when executing large numbers of asynchronous tasks, due to
10//! reduced per-task invocation overhead, and they provide a means of bounding
11//! and managing the resources, including threads, consumed when executing a
12//! collection of tasks.
13//!
14//! To be useful across a wide range of contexts, `ThreadPool` provides a number
15//! of adjustable parameters and extensibility hooks. However, programmers are
16//! urged to use the more convenient builder methods,
17//! [`fixed_size`](struct.ThreadPool.html#method.fixed_size), and
18//! [`single_thread`](struct.ThreadPool.html#method.single_thread) (single
19//! background thread), that preconfigure settings for the most common usage
20//! scenarios. Otherwise, use the following guide when manually configuring and
21//! tuning a `ThreadPool`.
22
23#![deny(warnings, missing_docs, missing_debug_implementations)]
24
25extern crate num_cpus;
26extern crate two_lock_queue;
27
28mod task;
29mod state;
30mod thread_pool;
31
32pub use task::{Task, TaskBox};
33pub use thread_pool::{Builder, Sender, ThreadPool};
34
35pub use two_lock_queue::{
36 SendError,
37 TrySendError,
38 SendTimeoutError,
39};