blocking: clarify that spawn_blocking is aborted if not yet started (#7501)

This commit is contained in:
Alice Ryhl
2025-08-01 10:32:37 +00:00
committed by GitHub
parent 1bc50825f3
commit e47565b086
+9 -6
View File
@@ -109,12 +109,15 @@ cfg_rt! {
/// running normally. The exception is if the task has not started running
/// yet; in that case, calling `abort` may prevent the task from starting.
///
/// When you shut down the executor, it will wait indefinitely for all blocking operations to
/// finish. You can use [`shutdown_timeout`] to stop waiting for them after a
/// certain timeout. Be aware that this will still not cancel the tasks — they
/// are simply allowed to keep running after the method returns. It is possible
/// for a blocking task to be cancelled if it has not yet started running, but this
/// is not guaranteed.
/// When you shut down the executor, it will attempt to `abort` all tasks
/// including `spawn_blocking` tasks. However, `spawn_blocking` tasks
/// cannot be aborted once they start running, which means that runtime
/// shutdown will wait indefinitely for all started `spawn_blocking` to
/// finish running. You can use [`shutdown_timeout`] to stop waiting for
/// them after a certain timeout. Be aware that this will still not cancel
/// the tasks — they are simply allowed to keep running after the method
/// returns. It is possible for a blocking task to be cancelled if it has
/// not yet started running, but this is not guaranteed.
///
/// Note that if you are using the single threaded runtime, this function will
/// still spawn additional threads for blocking operations. The current-thread