mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
Improve runtime threading options docs
This commit is contained in:
parent
b24ad9fe86
commit
0c0f682010
@ -149,7 +149,7 @@ impl Builder {
|
|||||||
|
|
||||||
/// Set the core number of worker threads for the `Runtime`'s thread pool.
|
/// Set the core number of worker threads for the `Runtime`'s thread pool.
|
||||||
///
|
///
|
||||||
/// This must be a number between 1 and 32,768 though it is advised to keep
|
/// This should be a number between 1 and 32,768 though it is advised to keep
|
||||||
/// this value on the smaller side.
|
/// this value on the smaller side.
|
||||||
///
|
///
|
||||||
/// The default value is the number of cores available to the system.
|
/// The default value is the number of cores available to the system.
|
||||||
@ -167,24 +167,25 @@ impl Builder {
|
|||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn core_threads(&mut self, val: usize) -> &mut Self {
|
pub fn core_threads(&mut self, val: usize) -> &mut Self {
|
||||||
|
assert_ne!(val, 0, "Core threads cannot be zero");
|
||||||
self.core_threads = val;
|
self.core_threads = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specifies limit for threads, spawned by the Runtime.
|
/// Specifies limit for threads, spawned by the Runtime.
|
||||||
///
|
///
|
||||||
/// This is number of threads to be used outside of Runtime core threads.
|
/// This is number of threads to be used by Runtime, including `core_threads`
|
||||||
/// In the current implementation it is used to cap number of threads spawned when using
|
/// Having `max_threads` less than `core_threads` results in invalid configuration
|
||||||
/// blocking annotation
|
/// when building multi-threaded `Runtime`, which would cause a panic.
|
||||||
|
///
|
||||||
|
/// Similarly to the `core_threads`, this number should be between 1 and 32,768.
|
||||||
///
|
///
|
||||||
/// The default value is 512.
|
/// The default value is 512.
|
||||||
///
|
///
|
||||||
/// When multi-threaded runtime is not used, will act as limit on additional threads.
|
/// When multi-threaded runtime is not used, will act as limit on additional threads.
|
||||||
///
|
///
|
||||||
/// Otherwise it limits additional threads as following: `max_threads - core_threads`
|
/// Otherwise as `core_threads` are always active, it limits additional threads (e.g. for
|
||||||
///
|
/// blocking annotations) as `max_threads - core_threads`.
|
||||||
/// If `core_threads` is greater than `max_threads`, then core_threads is capped
|
|
||||||
/// by `max_threads`
|
|
||||||
pub fn max_threads(&mut self, val: usize) -> &mut Self {
|
pub fn max_threads(&mut self, val: usize) -> &mut Self {
|
||||||
assert_ne!(val, 0, "Thread limit cannot be zero");
|
assert_ne!(val, 0, "Thread limit cannot be zero");
|
||||||
self.max_threads = val;
|
self.max_threads = val;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user