Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tokio-util/src/task/join_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ where
self.insert(key, task);
}

/// Spawn the provided task on the current [`LocalSet`] and store it in this
/// Spawn the provided task on the current [`LocalSet`] or [`LocalRuntime`] and store it in this
/// `JoinMap` with the provided key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to keep the line length consistent with the rest of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, I fixed the formatting, let me know if now it makes sense to you

///
/// If a task previously existed in the `JoinMap` for this key, that task
Expand All @@ -355,9 +355,10 @@ where
///
/// # Panics
///
/// This method panics if it is called outside of a `LocalSet`.
/// This method panics if it is called outside of a `LocalSet` or `LocalRuntime`.
///
/// [`LocalSet`]: tokio::task::LocalSet
/// [`LocalRuntime`]: tokio::runtime::LocalRuntime
/// [`join_next`]: Self::join_next
#[track_caller]
pub fn spawn_local<F>(&mut self, key: K, task: F)
Expand Down
7 changes: 6 additions & 1 deletion tokio-util/src/task/task_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,16 @@ impl TaskTracker {
handle.spawn(self.track_future(task))
}

/// Spawn the provided future on the current [`LocalSet`], and track it in this `TaskTracker`.
/// Spawn the provided future on the current [`LocalSet`] or [`LocalRuntime`], and track it in this `TaskTracker`.
///
/// This is equivalent to `tokio::task::spawn_local(tracker.track_future(task))`.
///
/// # Panics
///
/// This method panics if it is called outside of a `LocalSet` or `LocalRuntime`.
///
/// [`LocalSet`]: tokio::task::LocalSet
/// [`LocalRuntime`]: tokio::runtime::LocalRuntime
#[inline]
#[track_caller]
#[cfg(feature = "rt")]
Expand Down
5 changes: 3 additions & 2 deletions tokio/src/task/join_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<T: 'static> JoinSet<T> {
self.insert(handle.spawn(task))
}

/// Spawn the provided task on the current [`LocalSet`] and store it in this
/// Spawn the provided task on the current [`LocalSet`] or [`LocalRuntime`] and store it in this
/// `JoinSet`, returning an [`AbortHandle`] that can be used to remotely
/// cancel the task.
///
Expand All @@ -177,9 +177,10 @@ impl<T: 'static> JoinSet<T> {
///
/// # Panics
///
/// This method panics if it is called outside of a `LocalSet`.
/// This method panics if it is called outside of a `LocalSet`or `LocalRuntime`.
///
/// [`LocalSet`]: crate::task::LocalSet
/// [`LocalRuntime`]: crate::runtime::LocalRuntime
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(&mut self, task: F) -> AbortHandle
Expand Down
6 changes: 3 additions & 3 deletions tokio/src/task/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ cfg_rt! {
///
/// # Panics
///
/// This function panics if called outside of a [`LocalSet`].
/// This function panics if called outside of a [`LocalSet`] or [`LocalRuntime`].
///
/// Note that if [`tokio::spawn`] is used from within a `LocalSet`, the
/// resulting new task will _not_ be inside the `LocalSet`, so you must use
Expand Down Expand Up @@ -428,7 +428,7 @@ cfg_rt! {
unsafe { handle.spawn_local(task, id, meta.spawned_at) }
} else {
match CURRENT.with(|LocalData { ctx, .. }| ctx.get()) {
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or LocalRuntime"),
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or `runtime::LocalRuntime`"),
Some(cx) => cx.spawn(future.take().unwrap(), meta)
}
})
Expand All @@ -438,7 +438,7 @@ cfg_rt! {
Ok(None) => panic!("Local tasks can only be spawned on a LocalRuntime from the thread the runtime was created on"),
Ok(Some(join_handle)) => join_handle,
Err(_) => match CURRENT.with(|LocalData { ctx, .. }| ctx.get()) {
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or LocalRuntime"),
None => panic!("`spawn_local` called from outside of a `task::LocalSet` or `runtime::LocalRuntime`"),
Some(cx) => cx.spawn(future.unwrap(), meta)
}
}
Expand Down