summaryrefslogtreecommitdiffstats
path: root/tokio/src/task/spawn.rs
diff options
context:
space:
mode:
authorAlice Ryhl <alice@ryhl.io>2020-03-17 22:59:26 +0100
committerGitHub <noreply@github.com>2020-03-17 22:59:26 +0100
commit602ad2e0ba41467f08052e152d5808ee6a695afe (patch)
treee43ddc4f67eaac509fb084c23a42856b2b8931a2 /tokio/src/task/spawn.rs
parent06a4d895ec8787386058a24b422dfa9a8514bc8e (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/spawn.rs')
-rw-r--r--tokio/src/task/spawn.rs4
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