From 657fd883d2ba5d110b2fd522ce9bd08947e03d7c Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Tue, 27 Jun 2023 18:05:09 +0100 Subject: [PATCH] task: add guarantee about when a spawned task may be polled (#5816) --- tokio/src/task/spawn.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokio/src/task/spawn.rs b/tokio/src/task/spawn.rs index 20f74d346..23a46d745 100644 --- a/tokio/src/task/spawn.rs +++ b/tokio/src/task/spawn.rs @@ -15,6 +15,10 @@ cfg_rt! { /// different thread to be executed. The specifics depend on the current /// [`Runtime`](crate::runtime::Runtime) configuration. /// + /// It is guaranteed that spawn will not synchronously poll the task being spawned. + /// This means that calling spawn while holding a lock does not pose a risk of + /// deadlocking with the spawned task. + /// /// There is no guarantee that a spawned task will execute to completion. /// When a runtime is shutdown, all outstanding tasks are dropped, /// regardless of the lifecycle of that task.