id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | ///
/// 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
///
/// This method panics if called outside of a Tokio runtime.
///
/// [`AbortHandle`]: crate::task:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | /// `JoinSet`, returning an [`AbortHandle`] that can be used to remotely
/// cancel the task.
///
/// 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
///
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | }
/// Spawn the blocking code on the blocking threadpool and store
/// it in this `JoinSet`, returning an [`AbortHandle`] that can be
/// used to remotely cancel the task.
///
/// # Examples
///
/// Spawn multiple blocking tasks and wait for them.
///
/// ```
/// use tokio::task... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
self.insert(crate::runtime::spawn_blocking(f))
}
/// Spawn the blocking code on the blocking threadpool of the
/// provided runtime and store it in this `JoinSet`, returning an
/// [`AbortHandle`] that can be used... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
std::future::poll_fn(|cx| self.poll_join_next(cx)).await
}
/// Waits until one of the tasks in the set completes and returns its
/// output, along with the [task ID] of the completed task.
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | let _entry = entry.remove();
return Some(res);
}
}
}
/// Tries to join one of the tasks in the set that has completed and return its output,
/// along with the [task ID] of the completed task.
///
/// Returns `None` if there are no completed tasks, or if the set... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | /// assert_eq!(output, vec![2, 1, 0]);
/// }
/// ```
///
/// Equivalent implementation of `join_all`, using [`join_next`] and loop.
///
/// ```
/// use tokio::task::JoinSet;
/// use std::panic;
///
/// #[tokio::main]
/// async fn main() {
/// let mut set = JoinSet... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | }
output
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a loop until the `JoinSet` is empty.
pub fn abort_all(&mut self) {
self.inner.for_each... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | ///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task::coop#cooperative-scheduling
pub fn poll_join_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<T, JoinEr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | /// `poll_join_next`, only the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | if let Poll::Ready(res) = res {
let entry = entry.remove();
// If the task succeeded, add the task ID to the output. Otherwise, the
// `JoinError` will already have the task's ID.
Poll::Ready(Some(res.map(|output| (entry.id(), output))))
} else {
// A ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | /// The main example from [`JoinSet`]'s documentation can also be written using [`collect`]:
///
/// ```
/// use tokio::task::JoinSet;
///
/// #[tokio::main]
/// async fn main() {
/// let mut set: JoinSet<_> = (0..10).map(|i| async move { i }).collect();
///
/// let mut seen = [false; 10];
/// while let Som... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
impl<'a, T: 'static> Builder<'a, T> {
/// Assigns a name to the task which will be spawned.
pub fn name(self, name: &'a str) -> Self {
let builder = self.builder.name(name);
Self { builder, ..self }
}
/// Spawn the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | /// [runtime handle]: crate::runtime::Handle
#[track_caller]
pub fn spawn_on<F>(self, future: F, handle: &Handle) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_on(future, handle)?))
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | /// An [`AbortHandle`] that can be used to remotely cancel the task.
///
/// [`JoinSet`]: crate::task::JoinSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_blocking_on<F>(self, f: F, handle: &Handle) -> std::io::Result<AbortHandle>
where
F: FnOnce() -> T,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | ///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///
/// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> std::io::Result<AbortHan... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 761 | 791 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | }
output
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a loop until the `JoinSet` is empty.
pub fn abort_all(&mut self) {
self.inner.for_each... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | ///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task::coop#cooperative-scheduling
pub fn poll_join_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<T, JoinEr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | /// `poll_join_next`, only the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | }
output
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a loop until the `JoinSet` is empty.
pub fn abort_all(&mut self) {
self.inner.for_each... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c032ea02030b55ef3b16000cd3f51d19009469da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c032ea02030b55ef3b16000cd3f51d19009469da/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | ///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task#cooperative-scheduling
pub fn poll_join_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<T, JoinError>>>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c032ea02030b55ef3b16000cd3f51d19009469da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c032ea02030b55ef3b16000cd3f51d19009469da/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | /// `poll_join_next`, only the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c032ea02030b55ef3b16000cd3f51d19009469da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c032ea02030b55ef3b16000cd3f51d19009469da/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:2 | /// }
///
/// let mut seen = [false; 10];
/// while let Some(res) = set.join_next().await {
/// let idx = res.unwrap();
/// seen[idx] = true;
/// }
///
/// for i in 0..10 {
/// assert!(seen[i]);
/// }
/// }
/// ```
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
pub struct ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join_set.rs:3 | self.inner.len()
}
/// Returns whether the `JoinSet` is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}
impl<T: 'static> JoinSet<T> {
/// Returns a [`Builder`] that can be used to configure a task prior to
/// spawning it on this `JoinSet`.
///
/// # Examples
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | /// that can be used to remotely cancel the task.
///
/// 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
///
/// This method panics if called outside of a Tokio ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | /// Spawn the provided task on the current [`LocalSet`] and store it in this
/// `JoinSet`, returning an [`AbortHandle`] that can be used to remotely
/// cancel the task.
///
/// The provided future will start running in the background immediately
/// when this method is called, even if you don't aw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | self.insert(local_set.spawn_local(task))
}
/// Spawn the blocking code on the blocking threadpool and store
/// it in this `JoinSet`, returning an [`AbortHandle`] that can be
/// used to remotely cancel the task.
///
/// # Examples
///
/// Spawn multiple blocking tasks and wait for them... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
self.insert(crate::runtime::spawn_blocking(f))
}
/// Spawn the blocking code on the blocking threadpool of the
/// provided runtime and store it in this `Jo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// statement and some other branch completes first, it is guaranteed that no tasks were
/// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
std::future::poll_fn(|cx| self.poll_join_next(cx)).await
}
/// Waits until one of the tasks in the set co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | });
if let Poll::Ready(res) = res {
let _entry = entry.remove();
return Some(res);
}
}
}
/// Tries to join one of the tasks in the set that has completed and return its output,
/// along with the [task ID] of the completed task.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | /// i
/// });
/// }
///
/// let output = set.join_all().await;
/// assert_eq!(output, vec![2, 1, 0]);
/// }
/// ```
///
/// Equivalent implementation of `join_all`, using [`join_next`] and loop.
///
/// ```
/// use tokio::task::JoinSet;
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | match res {
Ok(t) => output.push(t),
Err(err) if err.is_panic() => panic::resume_unwind(err.into_panic()),
Err(err) => panic!("{err}"),
}
}
output
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | /// * `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the tasks that completed.
/// * `Poll::Ready(Some(Err(err)))` if one of the tasks in this `JoinSet` has panicked or been
/// aborted. The `err` is the `JoinError`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | ///
/// If this returns `Poll::Ready(Some(_))`, then the task that completed is removed from the set.
///
/// When the method returns `Poll::Pending`, the `Waker` in the provided `Context` is scheduled
/// to receive a wakeup when a task in the `JoinSet` completes. Note that on multiple calls to
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | // The waker was set by `pop_notified`.
return Poll::Pending;
}
}
};
let res = entry.with_value_and_context(|jh, ctx| Pin::new(jh).poll(ctx));
if let Poll::Ready(res) = res {
let entry = entry.remove();
// If the task succ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | /// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can also be written using [`collect`]:
///
/// ```
/// use tokio::task::JoinSet;
///
/// #[tokio::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | set
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
impl<'a, T: 'static> Builder<'a, T> {
/// Assigns a name to the task which will be spawned.
pub fn name(self, name: &'a str) -> Self {
let builde... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | ///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///
///
/// [`AbortHandle`]: crate::task::AbortHandle
/// [runtime handle]: crate::runtime::Handle
#[track_caller]
pub fn spawn_on<F>(self, future: F, handle: &Handle) -> std::io::Result<AbortH... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | /// Spawn the blocking code on the blocking threadpool of the provided
/// runtime handle with this builder's settings, and store it in the
/// [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///
/// [`JoinSet`]: crate::task::JoinSe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
}
/// Spawn the provided task on the provided [`LocalSet`] with this builder's
/// settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/task/join_set.rs | 761 | 798 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
self.insert(crate::runtime::spawn_blocking(f))
}
/// Spawn the blocking code on the blocking threadpool of the
/// provided runtime and store it in this `Jo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | cc70a211ad4ce71388c99e8af7480f3ddddbf602 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cc70a211ad4ce71388c99e8af7480f3ddddbf602/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// statement and some other branch completes first, it is guaranteed that no tasks were
/// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
crate::future::poll_fn(|cx| self.poll_join_next(cx)).await
}
/// Waits until one of the tasks in the set ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | cc70a211ad4ce71388c99e8af7480f3ddddbf602 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cc70a211ad4ce71388c99e8af7480f3ddddbf602/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | });
if let Poll::Ready(res) = res {
let _entry = entry.remove();
return Some(res);
}
}
}
/// Tries to join one of the tasks in the set that has completed and return its output,
/// along with the [task ID] of the completed task.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 4d0d89fb70d7e093c5401d0f8241275db673e70d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d0d89fb70d7e093c5401d0f8241275db673e70d/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | ///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// * `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 4d0d89fb70d7e093c5401d0f8241275db673e70d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d0d89fb70d7e093c5401d0f8241275db673e70d/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | // case.
cx.waker().wake_by_ref();
Poll::Pending
}
}
/// Polls for one of the tasks in the set to complete.
///
/// If this returns `Poll::Ready(Some(_))`, then the task that completed is removed from the set.
///
/// When the method returns `Poll::Pending`, the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 4d0d89fb70d7e093c5401d0f8241275db673e70d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d0d89fb70d7e093c5401d0f8241275db673e70d/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | // the `notified` list if the waker is notified in the `poll` call below.
let mut entry = match self.inner.pop_notified(cx.waker()) {
Some(entry) => entry,
None => {
if self.is_empty() {
return Poll::Ready(None);
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 4d0d89fb70d7e093c5401d0f8241275db673e70d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d0d89fb70d7e093c5401d0f8241275db673e70d/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | }
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
/// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can al... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 4d0d89fb70d7e093c5401d0f8241275db673e70d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4d0d89fb70d7e093c5401d0f8241275db673e70d/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// statement and some other branch completes first, it is guaranteed that no tasks were
/// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
crate::future::poll_fn(|cx| self.poll_join_next(cx)).await
}
/// Waits until one of the tasks in the set ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | e62c3e92692f795c407beadff580fa1380df5a26 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e62c3e92692f795c407beadff580fa1380df5a26/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | });
if let Poll::Ready(res) = res {
let _entry = entry.remove();
return Some(res);
}
}
}
/// Tries to join one of the tasks in the set that has completed and return its output,
/// along with the [task ID] of the completed task.
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | e62c3e92692f795c407beadff580fa1380df5a26 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e62c3e92692f795c407beadff580fa1380df5a26/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | T: Send,
{
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 0b31b2a19531f969a172bca77f2fd80d0d3b54ed | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b31b2a19531f969a172bca77f2fd80d0d3b54ed/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | where
F: Future<Output = T>,
F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
}
/// Spawn the provided task on the provided [`LocalSet`] with this builder's
/// settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`Abor... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 0b31b2a19531f969a172bca77f2fd80d0d3b54ed | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0b31b2a19531f969a172bca77f2fd80d0d3b54ed/tokio/src/task/join_set.rs | 641 | 680 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | // the `notified` list if the waker is notified in the `poll` call below.
let mut entry = match self.inner.pop_notified(cx.waker()) {
Some(entry) => entry,
None => {
if self.is_empty() {
return Poll::Ready(None);
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | }
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
impl<'a, T: 'static> Builder<'a, T> {
/// Assigns a name to the task which wil... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | }
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///
///
/// [`AbortHandle`]: crate::task::AbortHandle
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | {
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
}
/// Spawn the provided task on the provided [`LocalSet`] with this builder's
/// settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 12ce924fb9c1ffe0340b979fefa00d13ebf631c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12ce924fb9c1ffe0340b979fefa00d13ebf631c3/tokio/src/task/join_set.rs | 601 | 637 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// statement and some other branch completes first, it is guaranteed that no tasks were
/// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
crate::future::poll_fn(|cx| self.poll_join_next(cx)).await
}
/// Waits until one of the tasks in the set ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | while self.join_next().await.is_some() {}
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a loop until the `JoinSet` is empty.
pub fn abort_all(&mut self) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:10 | /// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task#cooperative-scheduling
pub fn poll_join_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<T, JoinError>>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | /// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// * `Poll::Ready(Some(Ok((id, value))))` if one of the tasks in this `JoinSet`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | let res = entry.with_value_and_context(|jh, ctx| Pin::new(jh).poll(ctx));
if let Poll::Ready(res) = res {
let entry = entry.remove();
// If the task succeeded, add the task ID to the output. Otherwise, the
// `JoinError` will already have the task's ID.
Poll::Rea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | /// Assigns a name to the task which will be spawned.
pub fn name(self, name: &'a str) -> Self {
let builder = self.builder.name(name);
Self { builder, ..self }
}
/// Spawn the provided task with this builder's settings and store it in the
/// [`JoinSet`], returning an [`AbortHandle`] t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | pub fn spawn_on<F>(self, future: F, handle: &Handle) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_on(future, handle)?))
}
/// Spawn the provided task on the current [`LocalSet`] with ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | #[track_caller]
pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self
.joinset
.insert(self.builder.spawn_local_on(future, local_set)?))
}
}
// Manual `Debug` imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7ccd3e0c6d0d1341bee4dd136eef38092e1aad11 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ccd3e0c6d0d1341bee4dd136eef38092e1aad11/tokio/src/task/join_set.rs | 561 | 584 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | while self.join_next().await.is_some() {}
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a loop until the `JoinSet` is empty.
pub fn abort_all(&mut self) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:10 | /// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task#cooperative-scheduling
fn poll_join_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<T, JoinError>>> {
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | /// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// * `Poll::Ready(Some(Ok((id, value))))` if one of the tasks in this `JoinSet`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | if let Poll::Ready(res) = res {
let entry = entry.remove();
// If the task succeeded, add the task ID to the output. Otherwise, the
// `JoinError` will already have the task's ID.
Poll::Ready(Some(res.map(|output| (entry.id(), output))))
} else {
// A ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | pub fn name(self, name: &'a str) -> Self {
let builder = self.builder.name(name);
Self { builder, ..self }
}
/// Spawn the provided task with this builder's settings and store it in the
/// [`JoinSet`], returning an [`AbortHandle`] that can be used to remotely
/// cancel the task.
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_on(future, handle)?))
}
/// Spawn the provided task on the current [`LocalSet`] with this builder's
/// settings, and store it in the [`JoinSet`].
///
/// # Retur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self
.joinset
.insert(self.builder.spawn_local_on(future, local_set)?))
}
}
// Manual `Debug` impl so that `Builder` ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | f6cb6e084babd72b8e37a770d962d740495585eb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f6cb6e084babd72b8e37a770d962d740495585eb/tokio/src/task/join_set.rs | 561 | 583 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | /// Spawn the provided task on the current [`LocalSet`] and store it in this
/// `JoinSet`, returning an [`AbortHandle`] that can be used to remotely
/// cancel the task.
///
/// The provided future will start running in the background immediately
/// when this method is called, even if you don't aw... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | self.insert(local_set.spawn_local(task))
}
fn insert(&mut self, jh: JoinHandle<T>) -> AbortHandle {
let abort = jh.abort_handle();
let mut entry = self.inner.insert_idle(jh);
// Set the waker that is notified when the task completes.
entry.with_value_and_context(|jh, ctx| jh.se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | /// [`JoinError::id`]: fn@crate::task::JoinError::id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub async fn join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>> {
crate::future::poll_fn(|cx| self.poll_join_next_with_id(cx)).await
}
/// Aborts all tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// If this returns `Poll::Ready(Some(_))`, then the task that completed is removed from the set.
///
/// When the method returns `Poll::Pending`, the `Waker` in the provided `Context` is scheduled
/// to receive a wakeup when a task in the `JoinSet` completes. Note that on multiple calls to
/// `poll_j... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | if let Poll::Ready(res) = res {
let _entry = entry.remove();
Poll::Ready(Some(res))
} else {
// A JoinHandle generally won't emit a wakeup without being ready unless
// the coop limit has been reached. We yield to the executor in this
// case.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:10 | fn poll_join_next_with_id(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<(Id, T), JoinError>>> {
// The call to `pop_notified` moves the entry to the `idle` list. It is moved back to
// the `notified` list if the waker is notified in the `poll` call below.
let mut ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | impl<T> fmt::Debug for JoinSet<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("JoinSet").field("len", &self.len()).finish()
}
}
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, fea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | #[track_caller]
pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
}
/// Spawn the provided task on the provided [`LocalSet`] with this builder's
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 06f1a601bb05b1aba9f95020a7fa7572899c588f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/tokio/src/task/join_set.rs | 481 | 522 |
tokio-rs/tokio:tokio/src/task/join_set.rs:3 | self.inner.len()
}
/// Returns whether the `JoinSet` is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}
impl<T: 'static> JoinSet<T> {
/// Returns a [`Builder`] that can be used to configure a task prior to
/// spawning it on this `JoinSet`.
///
/// # Examples
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | /// 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.
///
/// # Panics
///
/// This method panics if ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | /// Spawn the provided task on the current [`LocalSet`] and store it in this
/// `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 runn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | F: 'static,
{
self.insert(local_set.spawn_local(task))
}
fn insert(&mut self, jh: JoinHandle<T>) -> AbortHandle {
let abort = jh.abort_handle();
let mut entry = self.inner.insert_idle(jh);
// Set the waker that is notified when the task completes.
entry.with_value_a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | ///
/// [task ID]: crate::task::Id
/// [`JoinError::id`]: fn@crate::task::JoinError::id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub async fn join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>> {
crate::future::poll_fn(|cx| self.poll_join_next_with_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// Polls for one of the tasks in the set to complete.
///
/// If this returns `Poll::Ready(Some(_))`, then the task that completed is removed from the set.
///
/// When the method returns `Poll::Pending`, the `Waker` in the provided `Context` is scheduled
/// to receive a wakeup when a task in the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | let res = entry.with_value_and_context(|jh, ctx| Pin::new(jh).poll(ctx));
if let Poll::Ready(res) = res {
let _entry = entry.remove();
Poll::Ready(Some(res))
} else {
// A JoinHandle generally won't emit a wakeup without being ready unless
// the coop lim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:10 | /// [task ID]: crate::task::Id
#[cfg(tokio_unstable)]
fn poll_join_next_with_id(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<(Id, T), JoinError>>> {
// The call to `pop_notified` moves the entry to the `idle` list. It is moved back to
// the `notified` list if th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | }
}
impl<T> fmt::Debug for JoinSet<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("JoinSet").field("len", &self.len()).finish()
}
}
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | pub fn spawn<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's set... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | b248be2879dfc5e19d1b82561486efede74172ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b248be2879dfc5e19d1b82561486efede74172ba/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:3 | self.inner.len()
}
/// Returns whether the `JoinSet` is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}
impl<T: 'static> JoinSet<T> {
/// Returns a [`Builder`] that can be used to configure a task prior to
/// spawning it on this `JoinSet`.
///
/// # Examples
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | /// that can be used to remotely cancel the task.
///
/// # Panics
///
/// This method panics if called outside of a Tokio runtime.
///
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn<F>(&mut self, task: F) -> AbortHandle
where
F: Future<Output = T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | /// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(&mut self, task: F) -> AbortHandle
where
F: Future<Output = T>,
F: 'static,
{
self.insert(crate::task::spawn_local(task))
}
/// Spawn the provi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | ///
/// This method is cancel safe. If `join_next` is used as the event in a `tokio::select!`
/// statement and some other branch completes first, it is guaranteed that no tasks were
/// removed from this `JoinSet`.
pub async fn join_next(&mut self) -> Option<Result<T, JoinError>> {
crate::futur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | pub async fn shutdown(&mut self) {
self.abort_all();
while self.join_next().await.is_some() {}
}
/// Aborts all tasks on this `JoinSet`.
///
/// This does not remove the tasks from the `JoinSet`. To wait for the tasks to complete
/// cancellation, you should call `join_next` in a lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | /// * `Poll::Ready(None)` if the `JoinSet` is empty.
///
/// Note that this method may return `Poll::Pending` even if one of the tasks has completed.
/// This can happen if the [coop budget] is reached.
///
/// [coop budget]: crate::task#cooperative-scheduling
fn poll_join_next(&mut self, cx: &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | /// to receive a wakeup when a task in the `JoinSet` completes. Note that on multiple calls to
/// `poll_join_next`, only the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:10 | let res = entry.with_value_and_context(|jh, ctx| Pin::new(jh).poll(ctx));
if let Poll::Ready(res) = res {
let entry = entry.remove();
// If the task succeeded, add the task ID to the output. Otherwise, the
// `JoinError` will already have the task's ID.
Poll::Rea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/join_set.rs:11 | impl<'a, T: 'static> Builder<'a, T> {
/// Assigns a name to the task which will be spawned.
pub fn name(self, name: &'a str) -> Self {
let builder = self.builder.name(name);
Self { builder, ..self }
}
/// Spawn the provided task with this builder's settings and store it in the
/// [... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | #[track_caller]
pub fn spawn_on<F>(self, future: F, handle: &Handle) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_on(future, handle)?))
}
/// Spawn the provided task on the curren... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | /// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local_on<F>(self, future: F, local_set: &LocalSet) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self
.joinset
.insert(self.builder.spawn_local_on(fu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 01ebb0aa295956c3acf894127207d14ec628ada3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/01ebb0aa295956c3acf894127207d14ec628ada3/tokio/src/task/join_set.rs | 481 | 505 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.