summaryrefslogtreecommitdiffstats
path: root/tokio/tests
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-10-12 13:44:54 -0400
committerGitHub <noreply@github.com>2020-10-12 13:44:54 -0400
commit8880222036f37c6204c8466f25e828447f16dacb (patch)
treefd623afc20f73bbce65746a3d1b1b2731ecf30a5 /tokio/tests
parent0893841f31542b2b04c5050a8a4a3c45cf867e55 (diff)
rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876)
Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Carl Lerche <me@carllerche.com>
Diffstat (limited to 'tokio/tests')
-rw-r--r--tokio/tests/io_driver.rs3
-rw-r--r--tokio/tests/io_driver_drop.rs3
-rw-r--r--tokio/tests/rt_basic.rs3
-rw-r--r--tokio/tests/rt_common.rs15
-rw-r--r--tokio/tests/rt_threaded.rs17
-rw-r--r--tokio/tests/signal_drop_rt.rs3
-rw-r--r--tokio/tests/signal_multi_rt.rs3
-rw-r--r--tokio/tests/sync_rwlock.rs2
-rw-r--r--tokio/tests/task_blocking.rs53
-rw-r--r--tokio/tests/task_local.rs2
-rw-r--r--tokio/tests/task_local_set.rs27
-rw-r--r--tokio/tests/time_rt.rs6
12 files changed, 46 insertions, 91 deletions
diff --git a/tokio/tests/io_driver.rs b/tokio/tests/io_driver.rs
index 01be3659..82fb1021 100644
--- a/tokio/tests/io_driver.rs
+++ b/tokio/tests/io_driver.rs
@@ -45,8 +45,7 @@ fn test_drop_on_notify() {
// shutting down. Then, when the task handle is dropped, the task itself is
// dropped.
- let rt = runtime::Builder::new()
- .basic_scheduler()
+ let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
diff --git a/tokio/tests/io_driver_drop.rs b/tokio/tests/io_driver_drop.rs
index 2ee02a42..72c7ae25 100644
--- a/tokio/tests/io_driver_drop.rs
+++ b/tokio/tests/io_driver_drop.rs
@@ -45,8 +45,7 @@ fn drop_wakes() {
}
fn rt() -> runtime::Runtime {
- runtime::Builder::new()
- .basic_scheduler()
+ runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/rt_basic.rs b/tokio/tests/rt_basic.rs
index 3813c480..7b5b622b 100644
--- a/tokio/tests/rt_basic.rs
+++ b/tokio/tests/rt_basic.rs
@@ -129,8 +129,7 @@ fn acquire_mutex_in_drop() {
}
fn rt() -> Runtime {
- tokio::runtime::Builder::new()
- .basic_scheduler()
+ tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs
index 1273593f..a4091616 100644
--- a/tokio/tests/rt_common.rs
+++ b/tokio/tests/rt_common.rs
@@ -6,12 +6,11 @@
macro_rules! rt_test {
($($t:tt)*) => {
- mod basic_scheduler {
+ mod current_thread_scheduler {
$($t)*
fn rt() -> Arc<Runtime> {
- tokio::runtime::Builder::new()
- .basic_scheduler()
+ tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
@@ -23,9 +22,8 @@ macro_rules! rt_test {
$($t)*
fn rt() -> Arc<Runtime> {
- tokio::runtime::Builder::new()
- .threaded_scheduler()
- .core_threads(4)
+ tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(4)
.enable_all()
.build()
.unwrap()
@@ -37,9 +35,8 @@ macro_rules! rt_test {
$($t)*
fn rt() -> Arc<Runtime> {
- tokio::runtime::Builder::new()
- .threaded_scheduler()
- .core_threads(1)
+ tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(1)
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/rt_threaded.rs b/tokio/tests/rt_threaded.rs
index 1ac6ed32..90ebf6a6 100644
--- a/tokio/tests/rt_threaded.rs
+++ b/tokio/tests/rt_threaded.rs
@@ -18,10 +18,9 @@ use std::task::{Context, Poll};
#[test]
fn single_thread() {
// No panic when starting a runtime w/ a single thread
- let _ = runtime::Builder::new()
- .threaded_scheduler()
+ let _ = runtime::Builder::new_multi_thread()
.enable_all()
- .core_threads(1)
+ .worker_threads(1)
.build();
}
@@ -188,8 +187,7 @@ fn drop_threadpool_drops_futures() {
let a = num_inc.clone();
let b = num_dec.clone();
- let rt = runtime::Builder::new()
- .threaded_scheduler()
+ let rt = runtime::Builder::new_multi_thread()
.enable_all()
.on_thread_start(move || {
a.fetch_add(1, Relaxed);
@@ -228,8 +226,7 @@ fn start_stop_callbacks_called() {
let after_inner = after_start.clone();
let before_inner = before_stop.clone();
- let rt = tokio::runtime::Builder::new()
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.on_thread_start(move || {
after_inner.clone().fetch_add(1, Ordering::Relaxed);
@@ -329,8 +326,7 @@ fn multi_threadpool() {
// channel yields occasionally even if there are values ready to receive.
#[test]
fn coop_and_block_in_place() {
- let rt = tokio::runtime::Builder::new()
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
// Setting max threads to 1 prevents another thread from claiming the
// runtime worker yielded as part of `block_in_place` and guarantees the
// same thread will reclaim the worker at the end of the
@@ -380,8 +376,7 @@ fn coop_and_block_in_place() {
// Testing this does not panic
#[test]
fn max_threads() {
- let _rt = tokio::runtime::Builder::new()
- .threaded_scheduler()
+ let _rt = tokio::runtime::Builder::new_multi_thread()
.max_threads(1)
.build()
.unwrap();
diff --git a/tokio/tests/signal_drop_rt.rs b/tokio/tests/signal_drop_rt.rs
index 709e0d41..b931d7a9 100644
--- a/tokio/tests/signal_drop_rt.rs
+++ b/tokio/tests/signal_drop_rt.rs
@@ -37,8 +37,7 @@ fn dropping_loops_does_not_cause_starvation() {
}
fn rt() -> Runtime {
- tokio::runtime::Builder::new()
- .basic_scheduler()
+ tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/signal_multi_rt.rs b/tokio/tests/signal_multi_rt.rs
index 78319a75..1e0402c4 100644
--- a/tokio/tests/signal_multi_rt.rs
+++ b/tokio/tests/signal_multi_rt.rs
@@ -47,8 +47,7 @@ fn multi_loop() {
}
fn rt() -> Runtime {
- tokio::runtime::Builder::new()
- .basic_scheduler()
+ tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/sync_rwlock.rs b/tokio/tests/sync_rwlock.rs
index 87010b65..76760351 100644
--- a/tokio/tests/sync_rwlock.rs
+++ b/tokio/tests/sync_rwlock.rs
@@ -166,7 +166,7 @@ async fn write_order() {
}
// A single RwLock is contested by tasks in multiple threads
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread", worker_threads = 8)]
async fn multithreaded() {
let barrier = Arc::new(Barrier::new(5));
let rwlock = Arc::new(RwLock::<u32>::new(0));
diff --git a/tokio/tests/task_blocking.rs b/tokio/tests/task_blocking.rs
index 6cb11584..eec19cc1 100644
--- a/tokio/tests/task_blocking.rs
+++ b/tokio/tests/task_blocking.rs
@@ -28,7 +28,7 @@ async fn basic_blocking() {
}
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn block_in_blocking() {
// Run a few times
for _ in 0..100 {
@@ -51,7 +51,7 @@ async fn block_in_blocking() {
}
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
@@ -71,7 +71,7 @@ async fn block_in_block() {
}
}
-#[tokio::test(basic_scheduler)]
+#[tokio::test(flavor = "current_thread")]
#[should_panic]
async fn no_block_in_basic_scheduler() {
task::block_in_place(|| {});
@@ -79,10 +79,7 @@ async fn no_block_in_basic_scheduler() {
#[test]
fn yes_block_in_threaded_block_on() {
- let rt = runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = runtime::Runtime::new().unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
@@ -91,7 +88,7 @@ fn yes_block_in_threaded_block_on() {
#[test]
#[should_panic]
fn no_block_in_basic_block_on() {
- let rt = runtime::Builder::new().basic_scheduler().build().unwrap();
+ let rt = runtime::Builder::new_current_thread().build().unwrap();
rt.block_on(async {
task::block_in_place(|| {});
});
@@ -99,15 +96,11 @@ fn no_block_in_basic_block_on() {
#[test]
fn can_enter_basic_rt_from_within_block_in_place() {
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let outer = tokio::runtime::Runtime::new().unwrap();
outer.block_on(async {
tokio::task::block_in_place(|| {
- let inner = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let inner = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
@@ -120,15 +113,11 @@ fn can_enter_basic_rt_from_within_block_in_place() {
fn useful_panic_message_when_dropping_rt_in_rt() {
use std::panic::{catch_unwind, AssertUnwindSafe};
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let outer = tokio::runtime::Runtime::new().unwrap();
let result = catch_unwind(AssertUnwindSafe(|| {
outer.block_on(async {
- let _ = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let _ = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
});
@@ -147,14 +136,10 @@ fn useful_panic_message_when_dropping_rt_in_rt() {
#[test]
fn can_shutdown_with_zero_timeout_in_runtime() {
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let outer = tokio::runtime::Runtime::new().unwrap();
outer.block_on(async {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
rt.shutdown_timeout(Duration::from_nanos(0));
@@ -163,14 +148,10 @@ fn can_shutdown_with_zero_timeout_in_runtime() {
#[test]
fn can_shutdown_now_in_runtime() {
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let outer = tokio::runtime::Runtime::new().unwrap();
outer.block_on(async {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
rt.shutdown_background();
@@ -179,8 +160,7 @@ fn can_shutdown_now_in_runtime() {
#[test]
fn coop_disabled_in_block_in_place() {
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
+ let outer = tokio::runtime::Builder::new_multi_thread()
.enable_time()
.build()
.unwrap();
@@ -213,10 +193,7 @@ fn coop_disabled_in_block_in_place_in_block_on() {
let (done_tx, done_rx) = std::sync::mpsc::channel();
let done = done_tx.clone();
thread::spawn(move || {
- let outer = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let outer = tokio::runtime::Runtime::new().unwrap();
let (tx, rx) = tokio::sync::mpsc::unbounded_channel();
for i in 0..200 {
diff --git a/tokio/tests/task_local.rs b/tokio/tests/task_local.rs
index 58b58183..99815324 100644
--- a/tokio/tests/task_local.rs
+++ b/tokio/tests/task_local.rs
@@ -3,7 +3,7 @@ tokio::task_local! {
pub static FOO: bool;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn local() {
let j1 = tokio::spawn(REQ_ID.scope(1, async move {
assert_eq!(REQ_ID.get(), 1);
diff --git a/tokio/tests/task_local_set.rs b/tokio/tests/task_local_set.rs
index 1dc779ce..dda42809 100644
--- a/tokio/tests/task_local_set.rs
+++ b/tokio/tests/task_local_set.rs
@@ -11,7 +11,7 @@ use std::sync::atomic::Ordering::{self, SeqCst};
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::time::Duration;
-#[tokio::test(basic_scheduler)]
+#[tokio::test(flavor = "current_thread")]
async fn local_basic_scheduler() {
LocalSet::new()
.run_until(async {
@@ -20,7 +20,7 @@ async fn local_basic_scheduler() {
.await;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn local_threadpool() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
@@ -40,7 +40,7 @@ async fn local_threadpool() {
.await;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn localset_future_threadpool() {
thread_local! {
static ON_LOCAL_THREAD: Cell<bool> = Cell::new(false);
@@ -55,7 +55,7 @@ async fn localset_future_threadpool() {
local.await;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn localset_future_timers() {
static RAN1: AtomicBool = AtomicBool::new(false);
static RAN2: AtomicBool = AtomicBool::new(false);
@@ -99,7 +99,7 @@ async fn localset_future_drives_all_local_futs() {
assert!(RAN3.load(Ordering::SeqCst));
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn local_threadpool_timer() {
// This test ensures that runtime services like the timer are properly
// set for the local task set.
@@ -133,8 +133,7 @@ fn local_threadpool_blocking_in_place() {
ON_RT_THREAD.with(|cell| cell.set(true));
- let rt = runtime::Builder::new()
- .threaded_scheduler()
+ let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
@@ -149,7 +148,7 @@ fn local_threadpool_blocking_in_place() {
});
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn local_threadpool_blocking_run() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
@@ -177,7 +176,7 @@ async fn local_threadpool_blocking_run() {
.await;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn all_spawns_are_local() {
use futures::future;
thread_local! {
@@ -203,7 +202,7 @@ async fn all_spawns_are_local() {
.await;
}
-#[tokio::test(threaded_scheduler)]
+#[tokio::test(flavor = "multi_thread")]
async fn nested_spawn_is_local() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
@@ -246,10 +245,7 @@ fn join_local_future_elsewhere() {
ON_RT_THREAD.with(|cell| cell.set(true));
- let rt = runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = runtime::Runtime::new().unwrap();
let local = LocalSet::new();
local.block_on(&rt, async move {
let (tx, rx) = oneshot::channel();
@@ -491,8 +487,7 @@ async fn acquire_mutex_in_drop() {
}
fn rt() -> Runtime {
- tokio::runtime::Builder::new()
- .basic_scheduler()
+ tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
diff --git a/tokio/tests/time_rt.rs b/tokio/tests/time_rt.rs
index 78056f09..85db78db 100644
--- a/tokio/tests/time_rt.rs
+++ b/tokio/tests/time_rt.rs
@@ -28,11 +28,7 @@ fn timer_with_threaded_runtime() {
fn timer_with_basic_scheduler() {
use tokio::runtime::Builder;
- let rt = Builder::new()
- .basic_scheduler()
- .enable_all()
- .build()
- .unwrap();
+ let rt = Builder::new_current_thread().enable_all().build().unwrap();
let (tx, rx) = mpsc::channel();
rt.block_on(async move {