1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! # Thread Pool
//!
//! A thread pool allows you to execute asyncronous tasks without
//! creating new threads for each one. It improves the performance and
//! the resource utilization by limiting the number of threads.
//!
//! # Build a thread pool
//!
//! You can use the [`ThreadPoolBuilder`] to build a thread pool with
//! the configuration.
//!
//! # Examples
//!
//! ```
//! use jtp::ThreadPoolBuilder;
//! let mut thread_pool = ThreadPoolBuilder::default()
//! .set_core_pool_size(5)
//! .set_max_pool_size(10)
//! .set_channel_capacity(100)
//! .build()
//! .unwrap();
//!
//! // Even you start 50 tasks, there only be 10 threads at most at
//! // a time(the max_pool_size is setted as 10).
//! for _ in 0..50 {
//! thread_pool.execute(|| println!("Hello World")).unwrap();
//! }
//! ```
pub
pub use *;
pub use *;
type TPResult<T> = ;
/// An error returned from the [`ThreadPool::execute`].
///
/// [`ThreadPool::execute`]: crate::ThreadPool::execute