mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-17 05:46:44 +00:00
add timeout stress test
This commit is contained in:
parent
ab9d6554aa
commit
fd6ae40817
1 changed files with 22 additions and 0 deletions
22
tests/timeout.rs
Normal file
22
tests/timeout.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue