diff options
author | Alice Ryhl <alice@ryhl.io> | 2020-03-17 22:59:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-17 22:59:26 +0100 |
commit | 602ad2e0ba41467f08052e152d5808ee6a695afe (patch) | |
tree | e43ddc4f67eaac509fb084c23a42856b2b8931a2 /tokio/src/task | |
parent | 06a4d895ec8787386058a24b422dfa9a8514bc8e (diff) |
runtime: update the documentation around Handle (#2328)
This PR was prompted by having encountered a few cases of people not noticing that Runtime::handle can be cloned, and therefore not realizing it could be moved to another thread.
Diffstat (limited to 'tokio/src/task')
-rw-r--r-- | tokio/src/task/spawn.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tokio/src/task/spawn.rs b/tokio/src/task/spawn.rs index 4e19f559..fa5ff13b 100644 --- a/tokio/src/task/spawn.rs +++ b/tokio/src/task/spawn.rs @@ -16,6 +16,10 @@ doc_rt_core! { /// When a runtime is shutdown, all outstanding tasks are dropped, /// regardless of the lifecycle of that task. /// + /// This function must be called from the context of a Tokio runtime. Tasks running on + /// the Tokio runtime are always inside its context, but you can also enter the context + /// using the [`Handle::enter`](crate::runtime::Handle::enter()) method. + /// /// # Examples /// /// In this example, a server is started and `spawn` is used to start a new task |