You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
async-std/tests/timeout.rs

23 lines
560 B
Rust

use std::time::Duration;
use async_std::future::timeout;
use async_std::task;
#[test]
fn timeout_future_many() {
task::block_on(async {
let futures = (0..100)
.map(|i| {
timeout(Duration::from_millis(i * 10), async move {
task::sleep(Duration::from_millis(i)).await;
Ok::<(), async_std::future::TimeoutError>(())
})
})
.collect::<Vec<_>>();
for future in futures {
future.await.unwrap().unwrap();
}
});
}