summaryrefslogtreecommitdiffstats
path: root/tokio
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-10-12 15:15:40 -0400
committerGitHub <noreply@github.com>2020-10-12 15:15:40 -0400
commit07802b2c8487c6e70e39d0b0cd6bf7705fc88337 (patch)
tree38ac9bbd91124505c14aad66108c9ecab08a5d4e /tokio
parent891de3271dc3545fb09162e578251e9977d9789c (diff)
rt: `worker_threads` must be non-zero (#2947)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Diffstat (limited to 'tokio')
-rw-r--r--tokio/src/runtime/builder.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs
index f260eac6..27981d33 100644
--- a/tokio/src/runtime/builder.rs
+++ b/tokio/src/runtime/builder.rs
@@ -192,7 +192,12 @@ impl Builder {
/// // This will run the runtime and future on the current thread
/// rt.block_on(async move {});
/// ```
+ ///
+ /// # Panic
+ ///
+ /// This will panic if `val` is not larger than `0`.
pub fn worker_threads(&mut self, val: usize) -> &mut Self {
+ assert!(val > 0, "Worker threads cannot be set to 0");
self.worker_threads = Some(val);
self
}