diff options
author | Ivan Tham <pickfire@riseup.net> | 2020-12-01 00:34:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 17:34:11 +0100 |
commit | 72d6346c0d43d867002dc0cc5527fbd0b0e23c3f (patch) | |
tree | c558d1cb380cc67bfc56ea960a7d9e266259367a | |
parent | a85fdb884d961bb87a2f3d446c548802868e54cb (diff) |
macros: #[tokio::main] can be used on non-main (#3199)
-rw-r--r-- | tokio-macros/src/lib.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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 |