From 72d6346c0d43d867002dc0cc5527fbd0b0e23c3f Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 1 Dec 2020 00:34:11 +0800 Subject: macros: #[tokio::main] can be used on non-main (#3199) --- tokio-macros/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index 71c61e72..0acfbca5 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -35,6 +35,12 @@ use proc_macro::TokenStream; /// [Builder](../tokio/runtime/struct.Builder.html), which provides a more /// powerful interface. /// +/// Note: This macro can be used on any function and not just the `main` +/// function. Using it on a non-main function makes the function behave +/// as if it was synchronous by starting a new runtime each time it is called. +/// If the function is called often, it is preferable to create the runtime using +/// the runtime builder so the runtime can be reused across calls. +/// /// # Multi-threaded runtime /// /// To use the multi-threaded runtime, the macro can be configured using -- cgit v1.2.3