summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tokio-macros/src/lib.rs20
-rw-r--r--tokio/Cargo.toml2
-rw-r--r--tokio/src/lib.rs20
3 files changed, 17 insertions, 25 deletions
diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs
index fcdba2bf..bbcc3608 100644
--- a/tokio-macros/src/lib.rs
+++ b/tokio-macros/src/lib.rs
@@ -20,6 +20,7 @@ use proc_macro::TokenStream;
use quote::quote;
use std::num::NonZeroUsize;
+#[derive(Clone, Copy, PartialEq)]
enum Runtime {
Basic,
Threaded,
@@ -145,21 +146,10 @@ fn parse_knobs(
}
}
- let mut rt = quote! { tokio::runtime::Builder::new() };
- match (runtime, is_test) {
- (Some(Runtime::Threaded), _) => {
- if rt_threaded {
- rt = quote! { #rt.threaded_scheduler() }
- }
- }
- (Some(Runtime::Basic), _) => rt = quote! { #rt.basic_scheduler() },
- (None, true) => rt = quote! { #rt.basic_scheduler() },
- (None, false) => {
- if rt_threaded {
- rt = quote! { #rt.threaded_scheduler() }
- }
- }
- };
+ let mut rt = quote! { tokio::runtime::Builder::new().basic_scheduler() };
+ if rt_threaded && (runtime == Some(Runtime::Threaded) || (runtime.is_none() && !is_test)) {
+ rt = quote! { #rt.threaded_scheduler() };
+ }
if let Some(v) = core_threads.map(|v| v.get()) {
rt = quote! { #rt.core_threads(#v) };
}
diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml
index adb9425c..71f36a52 100644
--- a/tokio/Cargo.toml
+++ b/tokio/Cargo.toml
@@ -54,7 +54,7 @@ io-driver = ["mio", "lazy_static"]
io-util = ["memchr"]
# stdin, stdout, stderr
io-std = ["rt-core"]
-macros = ["rt-core", "tokio-macros"]
+macros = ["tokio-macros"]
net = ["dns", "tcp", "udp", "uds"]
process = [
"io-driver",
diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs
index fbb1bb0a..9658ccec 100644
--- a/tokio/src/lib.rs
+++ b/tokio/src/lib.rs
@@ -264,16 +264,18 @@ cfg_time! {
mod util;
cfg_macros! {
- cfg_rt_threaded! {
- #[cfg(not(test))] // Work around for rust-lang/rust#62127
- pub use tokio_macros::main_threaded as main;
- pub use tokio_macros::test_threaded as test;
- }
+ doc_rt_core! {
+ cfg_rt_threaded! {
+ #[cfg(not(test))] // Work around for rust-lang/rust#62127
+ pub use tokio_macros::main_threaded as main;
+ pub use tokio_macros::test_threaded as test;
+ }
- cfg_not_rt_threaded! {
- #[cfg(not(test))] // Work around for rust-lang/rust#62127
- pub use tokio_macros::main_basic as main;
- pub use tokio_macros::test_basic as test;
+ cfg_not_rt_threaded! {
+ #[cfg(not(test))] // Work around for rust-lang/rust#62127
+ pub use tokio_macros::main_basic as main;
+ pub use tokio_macros::test_basic as test;
+ }
}
}