mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-20 00:00:08 +02:00
task: clarify doc about tasks starting immediately (#5364)
This commit is contained in:
@@ -118,9 +118,9 @@ impl Handle {
|
||||
/// thread pool. The thread pool is then responsible for polling the future
|
||||
/// until it completes.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when `spawn` is called, even if you don't await the returned
|
||||
/// `JoinHandle`.
|
||||
///
|
||||
/// See [module level][mod] documentation for more details.
|
||||
///
|
||||
|
||||
@@ -163,9 +163,9 @@ impl Runtime {
|
||||
/// thread pool. The thread pool is then responsible for polling the future
|
||||
/// until it completes.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the
|
||||
/// background immediately when `spawn` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when `spawn` is called, even if you don't await the returned
|
||||
/// `JoinHandle`.
|
||||
///
|
||||
/// See [module level][mod] documentation for more details.
|
||||
///
|
||||
|
||||
@@ -11,9 +11,9 @@ cfg_rt! {
|
||||
/// An owned permission to join on a task (await its termination).
|
||||
///
|
||||
/// This can be thought of as the equivalent of [`std::thread::JoinHandle`]
|
||||
/// for a Tokio task rather than a thread. You do not need to `.await` the
|
||||
/// `JoinHandle` to make the task execute — it will start running in the
|
||||
/// background immediately.
|
||||
/// for a Tokio task rather than a thread. Note that the background task
|
||||
/// associated with this `JoinHandle` started running immediately when you
|
||||
/// called spawn, even if you have not yet awaited the `JoinHandle`.
|
||||
///
|
||||
/// A `JoinHandle` *detaches* the associated task when it is dropped, which
|
||||
/// means that there is no longer any handle to the task, and no way to `join`
|
||||
|
||||
+11
-13
@@ -120,9 +120,9 @@ impl<T: 'static> JoinSet<T> {
|
||||
/// Spawn the provided task on the `JoinSet`, returning an [`AbortHandle`]
|
||||
/// that can be used to remotely cancel the task.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when this method is called, even if you don't await anything on this
|
||||
/// `JoinSet`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@@ -143,9 +143,9 @@ impl<T: 'static> JoinSet<T> {
|
||||
/// `JoinSet` returning an [`AbortHandle`] that can be used to remotely
|
||||
/// cancel the task.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn_on` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when this method is called, even if you don't await anything on this
|
||||
/// `JoinSet`.
|
||||
///
|
||||
/// [`AbortHandle`]: crate::task::AbortHandle
|
||||
#[track_caller]
|
||||
@@ -162,9 +162,9 @@ impl<T: 'static> JoinSet<T> {
|
||||
/// `JoinSet`, returning an [`AbortHandle`] that can be used to remotely
|
||||
/// cancel the task.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn_local` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when this method is called, even if you don't await anything on this
|
||||
/// `JoinSet`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@@ -186,10 +186,8 @@ impl<T: 'static> JoinSet<T> {
|
||||
/// remotely cancel the task.
|
||||
///
|
||||
/// Unlike the [`spawn_local`] method, this method may be used to spawn local
|
||||
/// tasks when the `LocalSet` is _not_ running. You do not have to `.await`
|
||||
/// the returned `JoinHandle` to make the provided future start execution.
|
||||
/// It will start running immediately whenever the `LocalSet` is next
|
||||
/// started.
|
||||
/// tasks on a `LocalSet` that is _not_ currently running. The provided
|
||||
/// future will start running whenever the `LocalSet` is next started.
|
||||
///
|
||||
/// [`LocalSet`]: crate::task::LocalSet
|
||||
/// [`AbortHandle`]: crate::task::AbortHandle
|
||||
|
||||
@@ -289,9 +289,9 @@ cfg_rt! {
|
||||
///
|
||||
/// The spawned future will run on the same thread that called `spawn_local`.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn_local` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when `spawn_local` is called, even if you don't await the returned
|
||||
/// `JoinHandle`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@@ -417,10 +417,9 @@ impl LocalSet {
|
||||
/// This task is guaranteed to be run on the current thread.
|
||||
///
|
||||
/// Unlike the free function [`spawn_local`], this method may be used to
|
||||
/// spawn local tasks when the `LocalSet` is _not_ running. You do not have
|
||||
/// to `.await` the returned `JoinHandle` to make the provided future start
|
||||
/// execution. It will start running immediately whenever the `LocalSet` is
|
||||
/// next started.
|
||||
/// spawn local tasks when the `LocalSet` is _not_ running. The provided
|
||||
/// future will start running once the `LocalSet` is next started, even if
|
||||
/// you don't await the returned `JoinHandle`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
@@ -7,9 +7,9 @@ cfg_rt! {
|
||||
/// Spawns a new asynchronous task, returning a
|
||||
/// [`JoinHandle`](super::JoinHandle) for it.
|
||||
///
|
||||
/// You do not have to `.await` the returned `JoinHandle` to make the
|
||||
/// provided future start execution. It will start running in the background
|
||||
/// immediately when `spawn` is called.
|
||||
/// The provided future will start running in the background immediately
|
||||
/// when `spawn` is called, even if you don't await the returned
|
||||
/// `JoinHandle`.
|
||||
///
|
||||
/// Spawning a task enables the task to execute concurrently to other tasks. The
|
||||
/// spawned task may execute on the current thread, or it may be sent to a
|
||||
|
||||
Reference in New Issue
Block a user