summaryrefslogtreecommitdiffstats
path: root/tokio-macros
diff options
context:
space:
mode:
authorJon Gjengset <jon@thesquareplanet.com>2019-10-12 12:55:39 -0400
committerGitHub <noreply@github.com>2019-10-12 12:55:39 -0400
commit1cae04f8b380137137bb06e9d0ec0743aaa74c51 (patch)
treecd648689274b8928e18bc3076bec6ee939e5dd6b /tokio-macros
parent29f35df7f8953b03327297c7dd4692293f4c72ff (diff)
macros: Use more consistent runtime names (#1628)
As discussed in #1620, the attribute names for `#[tokio::main]` and `#[tokio::test]` aren't great. Specifically, they both use `single_thread` and `multi_thread`, as opposed to names that match the runtime names: `current_thread` and `threadpool`. This PR changes the former to the latter. Fixes #1627.
Diffstat (limited to 'tokio-macros')
-rw-r--r--tokio-macros/src/lib.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs
index 24a52021..00c0cc34 100644
--- a/tokio-macros/src/lib.rs
+++ b/tokio-macros/src/lib.rs
@@ -28,8 +28,8 @@ enum RuntimeType {
///
/// ## Options:
///
-/// - `single_thread` - Uses `current_thread`.
-/// - `multi_thread` - Uses multi-threaded runtime. Used by default.
+/// - `current_thread` - Uses the `current_thread` runtime.
+/// - `threadpool` - Uses the multi-threaded `threadpool` runtime. Used by default.
///
/// ## Function arguments:
///
@@ -40,7 +40,7 @@ enum RuntimeType {
/// ### Select runtime
///
/// ```rust
-/// #[tokio::main(single_thread)]
+/// #[tokio::main(current_thread)]
/// async fn main() {
/// println!("Hello world");
/// }
@@ -87,10 +87,10 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
return syn::Error::new_spanned(path, msg).to_compile_error().into();
}
match ident.unwrap().to_string().to_lowercase().as_str() {
- "multi_thread" => runtime = RuntimeType::Multi,
- "single_thread" => runtime = RuntimeType::Single,
+ "threadpool" => runtime = RuntimeType::Multi,
+ "current_thread" => runtime = RuntimeType::Single,
name => {
- let msg = format!("Unknown attribute {} is specified; expected `single_thread` or `multi_thread`", name);
+ let msg = format!("Unknown attribute {} is specified; expected `current_thread` or `threadpool`", name);
return syn::Error::new_spanned(path, msg).to_compile_error().into();
}
}
@@ -126,15 +126,15 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
///
/// ## Options:
///
-/// - `single_thread` - Uses `current_thread`. Used by default.
-/// - `multi_thread` - Uses multi-threaded runtime.
+/// - `current_thread` - Uses the `current_thread` runtime. Used by default.
+/// - `threadpool` - Uses multi-threaded runtime.
///
/// ## Usage
///
/// ### Select runtime
///
/// ```no_run
-/// #[tokio::test(multi_thread)]
+/// #[tokio::test(threadpool)]
/// async fn my_test() {
/// assert!(true);
/// }
@@ -189,10 +189,10 @@ pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
return syn::Error::new_spanned(path, msg).to_compile_error().into();
}
match ident.unwrap().to_string().to_lowercase().as_str() {
- "multi_thread" => runtime = RuntimeType::Multi,
- "single_thread" => runtime = RuntimeType::Single,
+ "threadpool" => runtime = RuntimeType::Multi,
+ "current_thread" => runtime = RuntimeType::Single,
name => {
- let msg = format!("Unknown attribute {} is specified; expected `single_thread` or `multi_thread`", name);
+ let msg = format!("Unknown attribute {} is specified; expected `current_thread` or `threadpool`", name);
return syn::Error::new_spanned(path, msg).to_compile_error().into();
}
}