mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
rt: worker_threads must be non-zero (#2947)
Co-authored-by: Alice Ryhl <[email protected]>
This commit is contained in:
co-authored by
Alice Ryhl
parent
891de3271d
commit
07802b2c84
+2
-3
@@ -45,9 +45,8 @@ fn many_signals(bench: &mut Bencher) {
|
|||||||
let num_signals = 10;
|
let num_signals = 10;
|
||||||
let (tx, mut rx) = mpsc::channel(num_signals);
|
let (tx, mut rx) = mpsc::channel(num_signals);
|
||||||
|
|
||||||
let rt = runtime::Builder::new_multi_thread()
|
// Intentionally single threaded to measure delays in propagating wakes
|
||||||
// Intentionally single threaded to measure delays in propagating wakes
|
let rt = runtime::Builder::new_current_thread()
|
||||||
.worker_threads(0)
|
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ fn uncontended_concurrent_multi(b: &mut Bencher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn uncontended_concurrent_single(b: &mut Bencher) {
|
fn uncontended_concurrent_single(b: &mut Bencher) {
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
let rt = tokio::runtime::Builder::new_current_thread()
|
||||||
.worker_threads(0)
|
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,12 @@ impl Builder {
|
|||||||
/// // This will run the runtime and future on the current thread
|
/// // This will run the runtime and future on the current thread
|
||||||
/// rt.block_on(async move {});
|
/// 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 {
|
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.worker_threads = Some(val);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user