summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--benches/mpsc.rs37
-rw-r--r--benches/scheduler.rs5
-rw-r--r--benches/signal.rs4
-rw-r--r--benches/spawn.rs14
-rw-r--r--benches/sync_rwlock.rs21
-rw-r--r--benches/sync_semaphore.rs22
-rw-r--r--tests-build/Cargo.toml1
-rw-r--r--tests-build/tests/fail/macros_core_no_default.rs6
-rw-r--r--tests-build/tests/fail/macros_core_no_default.stderr7
-rw-r--r--tests-build/tests/fail/macros_invalid_input.stderr4
-rw-r--r--tests-build/tests/macros.rs5
-rw-r--r--tests-integration/tests/macros_main.rs21
-rw-r--r--tests-integration/tests/rt_shell.rs32
-rw-r--r--tokio-macros/src/entry.rs409
-rw-r--r--tokio-macros/src/lib.rs238
-rw-r--r--tokio-test/src/lib.rs3
-rw-r--r--tokio-util/Cargo.toml1
-rw-r--r--tokio-util/src/cfg.rs10
-rw-r--r--tokio-util/src/codec/bytes_codec.rs2
-rw-r--r--tokio-util/src/context.rs12
-rw-r--r--tokio-util/src/lib.rs4
-rw-r--r--tokio-util/tests/context.rs11
-rw-r--r--tokio/Cargo.toml8
-rw-r--r--tokio/src/blocking.rs48
-rw-r--r--tokio/src/coop.rs17
-rw-r--r--tokio/src/fs/mod.rs4
-rw-r--r--tokio/src/future/block_on.rs15
-rw-r--r--tokio/src/future/mod.rs23
-rw-r--r--tokio/src/future/poll_fn.rs2
-rw-r--r--tokio/src/future/try_join.rs2
-rw-r--r--tokio/src/io/driver/mod.rs40
-rw-r--r--tokio/src/io/mod.rs4
-rw-r--r--tokio/src/io/stdio_common.rs6
-rw-r--r--tokio/src/lib.rs28
-rw-r--r--tokio/src/loom/mod.rs2
-rw-r--r--tokio/src/macros/cfg.rs90
-rw-r--r--tokio/src/macros/mod.rs2
-rw-r--r--tokio/src/macros/support.rs3
-rw-r--r--tokio/src/net/addr.rs45
-rw-r--r--tokio/src/park/either.rs2
-rw-r--r--tokio/src/park/mod.rs11
-rw-r--r--tokio/src/park/thread.rs25
-rw-r--r--tokio/src/process/unix/driver.rs2
-rw-r--r--tokio/src/runtime/basic_scheduler.rs2
-rw-r--r--tokio/src/runtime/blocking/mod.rs20
-rw-r--r--tokio/src/runtime/blocking/pool.rs3
-rw-r--r--tokio/src/runtime/builder.rs262
-rw-r--r--tokio/src/runtime/context.rs6
-rw-r--r--tokio/src/runtime/driver.rs20
-rw-r--r--tokio/src/runtime/enter.rs214
-rw-r--r--tokio/src/runtime/mod.rs648
-rw-r--r--tokio/src/runtime/spawner.rs2
-rw-r--r--tokio/src/runtime/task/error.rs2
-rw-r--r--tokio/src/runtime/task/join.rs2
-rw-r--r--tokio/src/runtime/task/mod.rs34
-rw-r--r--tokio/src/runtime/tests/loom_blocking.rs5
-rw-r--r--tokio/src/runtime/tests/loom_pool.rs5
-rw-r--r--tokio/src/runtime/thread_pool/atomic_cell.rs1
-rw-r--r--tokio/src/runtime/thread_pool/mod.rs4
-rw-r--r--tokio/src/runtime/thread_pool/worker.rs161
-rw-r--r--tokio/src/signal/registry.rs2
-rw-r--r--tokio/src/signal/unix/driver.rs45
-rw-r--r--tokio/src/signal/windows.rs3
-rw-r--r--tokio/src/stream/mod.rs2
-rw-r--r--tokio/src/sync/mod.rs6
-rw-r--r--tokio/src/sync/mpsc/bounded.rs8
-rw-r--r--tokio/src/sync/mpsc/chan.rs2
-rw-r--r--tokio/src/task/blocking.rs153
-rw-r--r--tokio/src/task/local.rs2
-rw-r--r--tokio/src/task/mod.rs19
-rw-r--r--tokio/src/task/yield_now.rs2
-rw-r--r--tokio/src/time/clock.rs38
-rw-r--r--tokio/src/time/driver/handle.rs72
-rw-r--r--tokio/src/time/driver/mod.rs2
-rw-r--r--tokio/src/util/linked_list.rs2
-rw-r--r--tokio/src/util/mod.rs16
-rw-r--r--tokio/src/util/slab.rs2
-rw-r--r--tokio/src/util/trace.rs4
-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
90 files changed, 1469 insertions, 1687 deletions
diff --git a/benches/mpsc.rs b/benches/mpsc.rs
index 2f3fe963..3f7e3fca 100644
--- a/benches/mpsc.rs
+++ b/benches/mpsc.rs
@@ -4,6 +4,13 @@ use tokio::sync::mpsc;
type Medium = [usize; 64];
type Large = [Medium; 64];
+fn rt() -> tokio::runtime::Runtime {
+ tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
+ .build()
+ .unwrap()
+}
+
fn create_1_medium(b: &mut Bencher) {
b.iter(|| {
black_box(&mpsc::channel::<Medium>(1));
@@ -43,11 +50,7 @@ fn send_large(b: &mut Bencher) {
}
fn contention_bounded(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = rt();
b.iter(|| {
rt.block_on(async move {
@@ -70,11 +73,7 @@ fn contention_bounded(b: &mut Bencher) {
}
fn contention_bounded_full(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = rt();
b.iter(|| {
rt.block_on(async move {
@@ -97,11 +96,7 @@ fn contention_bounded_full(b: &mut Bencher) {
}
fn contention_unbounded(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = rt();
b.iter(|| {
rt.block_on(async move {
@@ -124,11 +119,7 @@ fn contention_unbounded(b: &mut Bencher) {
}
fn uncontented_bounded(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = rt();
b.iter(|| {
rt.block_on(async move {
@@ -146,11 +137,7 @@ fn uncontented_bounded(b: &mut Bencher) {
}
fn uncontented_unbounded(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
- .build()
- .unwrap();
+ let rt = rt();
b.iter(|| {
rt.block_on(async move {
diff --git a/benches/scheduler.rs b/benches/scheduler.rs
index 801de72a..68a6d6a4 100644
--- a/benches/scheduler.rs
+++ b/benches/scheduler.rs
@@ -139,9 +139,8 @@ fn chained_spawn(b: &mut Bencher) {
}
fn rt() -> Runtime {
- runtime::Builder::new()
- .threaded_scheduler()
- .core_threads(4)
+ runtime::Builder::new_multi_thread()
+ .worker_threads(4)
.enable_all()
.build()
.unwrap()
diff --git a/benches/signal.rs b/benches/signal.rs
index 3a354c6b..fcad40da 100644
--- a/benches/signal.rs
+++ b/benches/signal.rs
@@ -45,9 +45,9 @@ fn many_signals(bench: &mut Bencher) {
let num_signals = 10;
let (tx, mut rx) = mpsc::channel(num_signals);
- let rt = runtime::Builder::new()
+ let rt = runtime::Builder::new_multi_thread()
// Intentionally single threaded to measure delays in propagating wakes
- .basic_scheduler()
+ .worker_threads(0)
.enable_all()
.build()
.unwrap();
diff --git a/benches/spawn.rs b/benches/spawn.rs
index f76daf3f..72a40357 100644
--- a/benches/spawn.rs
+++ b/benches/spawn.rs
@@ -10,8 +10,7 @@ async fn work() -> usize {
}
fn basic_scheduler_local_spawn(bench: &mut Bencher) {
- let runtime = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
runtime.block_on(async {
@@ -23,8 +22,7 @@ fn basic_scheduler_local_spawn(bench: &mut Bencher) {
}
fn threaded_scheduler_local_spawn(bench: &mut Bencher) {
- let runtime = tokio::runtime::Builder::new()
- .threaded_scheduler()
+ let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
runtime.block_on(async {
@@ -36,8 +34,7 @@ fn threaded_scheduler_local_spawn(bench: &mut Bencher) {
}
fn basic_scheduler_remote_spawn(bench: &mut Bencher) {
- let runtime = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let runtime = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
@@ -48,10 +45,7 @@ fn basic_scheduler_remote_spawn(bench: &mut Bencher) {
}
fn threaded_scheduler_remote_spawn(bench: &mut Bencher) {
- let runtime = tokio::runtime::Builder::new()
- .threaded_scheduler()
- .build()
- .unwrap();
+ let runtime = tokio::runtime::Builder::new_multi_thread().build().unwrap();
bench.iter(|| {
let h = runtime.spawn(work());
diff --git a/benches/sync_rwlock.rs b/benches/sync_rwlock.rs
index 30c66e49..46eeac0c 100644
--- a/benches/sync_rwlock.rs
+++ b/benches/sync_rwlock.rs
@@ -3,9 +3,8 @@ use std::sync::Arc;
use tokio::{sync::RwLock, task};
fn read_uncontended(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -22,9 +21,8 @@ fn read_uncontended(b: &mut Bencher) {
}
fn read_concurrent_uncontended_multi(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -51,8 +49,7 @@ fn read_concurrent_uncontended_multi(b: &mut Bencher) {
}
fn read_concurrent_uncontended(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
@@ -78,9 +75,8 @@ fn read_concurrent_uncontended(b: &mut Bencher) {
}
fn read_concurrent_contended_multi(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -108,8 +104,7 @@ fn read_concurrent_contended_multi(b: &mut Bencher) {
}
fn read_concurrent_contended(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
diff --git a/benches/sync_semaphore.rs b/benches/sync_semaphore.rs
index 32d4aa2b..19a1dd33 100644
--- a/benches/sync_semaphore.rs
+++ b/benches/sync_semaphore.rs
@@ -3,9 +3,8 @@ use std::sync::Arc;
use tokio::{sync::Semaphore, task};
fn uncontended(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -27,9 +26,8 @@ async fn task(s: Arc<Semaphore>) {
}
fn uncontended_concurrent_multi(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -51,8 +49,8 @@ fn uncontended_concurrent_multi(b: &mut Bencher) {
}
fn uncontended_concurrent_single(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(0)
.build()
.unwrap();
@@ -73,9 +71,8 @@ fn uncontended_concurrent_single(b: &mut Bencher) {
}
fn contended_concurrent_multi(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .core_threads(6)
- .threaded_scheduler()
+ let rt = tokio::runtime::Builder::new_multi_thread()
+ .worker_threads(6)
.build()
.unwrap();
@@ -97,8 +94,7 @@ fn contended_concurrent_multi(b: &mut Bencher) {
}
fn contended_concurrent_single(b: &mut Bencher) {
- let rt = tokio::runtime::Builder::new()
- .basic_scheduler()
+ let rt = tokio::runtime::Builder::new_current_thread()
.build()
.unwrap();
diff --git a/tests-build/Cargo.toml b/tests-build/Cargo.toml
index 68231d71..e76621b4 100644
--- a/tests-build/Cargo.toml
+++ b/tests-build/Cargo.toml
@@ -7,6 +7,7 @@ publish = false
[features]
full = ["tokio/full"]
+rt-core = ["tokio/rt-core", "tokio/macros"]
[dependencies]
tokio = { path = "../tokio", optional = true }
diff --git a/tests-build/tests/fail/macros_core_no_default.rs b/tests-build/tests/fail/macros_core_no_default.rs
new file mode 100644
index 00000000..23f8847d
--- /dev/null
+++ b/tests-build/tests/fail/macros_core_no_default.rs
@@ -0,0 +1,6 @@
+use tests_build::tokio;
+
+#[tokio::main]
+async fn my_fn() {}
+
+fn main() {}
diff --git a/tests-build/tests/fail/macros_core_no_default.stderr b/tests-build/tests/fail/macros_core_no_default.stderr
new file mode 100644
index 00000000..a3ae32cd
--- /dev/null
+++ b/tests-build/tests/fail/macros_core_no_default.stderr
@@ -0,0 +1,7 @@
+error: The default runtime flavor is `multi_thread`, but the `rt-threaded` feature is disabled.
+ --> $DIR/macros_core_no_default.rs:3:1
+ |
+3 | #[tokio::main]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests-build/tests/fail/macros_invalid_input.stderr b/tests-build/tests/fail/macros_invalid_input.stderr
index 96fdcb17..4c68bd93 100644
--- a/tests-build/tests/fail/macros_invalid_input.stderr
+++ b/tests-build/tests/fail/macros_invalid_input.stderr
@@ -4,7 +4,7 @@ error: the async keyword is missing from the function declaration
4 | fn main_is_not_async() {}
| ^^
-error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
+error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`
--> $DIR/macros_invalid_input.rs:6:15
|
6 | #[tokio::main(foo)]
@@ -28,7 +28,7 @@ error: the test function cannot accept arguments
16 | async fn test_fn_has_args(_x: u8) {}
| ^^^^^^
-error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
+error: Unknown attribute foo is specified; expected one of: `flavor`, `worker_threads`
--> $DIR/macros_invalid_input.rs:18:15
|
18 | #[tokio::test(foo)]
diff --git a/tests-build/tests/macros.rs b/tests-build/tests/macros.rs
index 170db227..a12a20ef 100644
--- a/tests-build/tests/macros.rs
+++ b/tests-build/tests/macros.rs
@@ -1,9 +1,12 @@
#[test]
-fn compile_fail() {
+fn compile_fail_full() {
let t = trybuild::TestCases::new();