summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--benches/signal.rs5
-rw-r--r--benches/sync_semaphore.rs3
-rw-r--r--tokio/src/runtime/builder.rs5
3 files changed, 8 insertions, 5 deletions
diff --git a/benches/signal.rs b/benches/signal.rs
index fcad40da..4d5f58fd 100644
--- a/benches/signal.rs
+++ b/benches/signal.rs
@@ -45,9 +45,8 @@ fn many_signals(bench: &mut Bencher) {
let num_signals = 10;
let (tx, mut rx) = mpsc::channel(num_signals);
- let rt = runtime::Builder::new_multi_thread()
- // Intentionally single threaded to measure delays in propagating wakes
- .worker_threads(0)
+ // Intentionally single threaded to measure delays in propagating wakes
+ let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
diff --git a/benches/sync_semaphore.rs b/benches/sync_semaphore.rs
index 19a1dd33..17b26148 100644
--- a/benches/sync_semaphore.rs
+++ b/benches/sync_semaphore.rs
@@ -49,8 +49,7 @@ fn uncontended_concurrent_multi(b: &mut Bencher) {
}
fn uncontended_concurrent_single(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new_multi_thread()
- .worker_threads(0)
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
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
}