task: fix flaky joinmap test during abort (#7509)

This commit is contained in:
Conrad Ludgate 2025-08-03 19:00:33 +01:00 committed by GitHub
parent cf6b50a3fd
commit f1d3b065b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,8 +69,8 @@ use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet};
/// async fn main() {
/// let mut map = JoinMap::new();
///
/// map.spawn("hello world", async move { /* ... */ });
/// map.spawn("goodbye world", async move { /* ... */});
/// map.spawn("hello world", std::future::ready(1));
/// map.spawn("goodbye world", std::future::pending());
///
/// // Look up the "goodbye world" task in the map and abort it.
/// let aborted = map.abort("goodbye world");
@ -85,7 +85,7 @@ use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet};
/// assert!(res.unwrap_err().is_cancelled());
/// } else {
/// // Other tasks should complete normally.
/// assert!(res.is_ok());
/// assert_eq!(res.unwrap(), 1);
/// }
/// }
/// }
@ -495,12 +495,12 @@ where
/// ```
/// use tokio_util::task::JoinMap;
///
/// # #[tokio::main]
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() {
/// let mut map = JoinMap::new();
///
/// map.spawn("hello world", async move { /* ... */ });
/// map.spawn("goodbye world", async move { /* ... */});
/// map.spawn("hello world", std::future::ready(1));
/// map.spawn("goodbye world", std::future::pending());
///
/// // Look up the "goodbye world" task in the map and abort it.
/// map.abort("goodbye world");
@ -511,7 +511,7 @@ where
/// assert!(res.unwrap_err().is_cancelled());
/// } else {
/// // Other tasks should complete normally.
/// assert!(res.is_ok());
/// assert_eq!(res.unwrap(), 1);
/// }
/// }
/// # }