for rt in rt_combinations() {
rt.block_on(async { letmut jhs = vec![];
// sleep outside of the worker threads let now = Instant::now();
tokio::time::sleep(Duration::from_millis(10)).await;
assert!(now.elapsed() >= Duration::from_millis(10));
for _ in0..N { let jh = tokio::spawn(asyncmove { // sleep inside of the worker threads let now = Instant::now();
tokio::time::sleep(Duration::from_millis(10)).await;
assert!(now.elapsed() >= Duration::from_millis(10));
});
jhs.push(jh);
}
for jh in jhs {
jh.await.unwrap();
}
});
}
}
#[test] fn timeout() { const N: u32 = 512;
for rt in rt_combinations() {
rt.block_on(async { letmut jhs = vec![];
// timeout outside of the worker threads let now = Instant::now();
tokio::time::timeout(Duration::from_millis(10), std::future::pending::<()>())
.await
.expect_err("timeout should occur");
assert!(now.elapsed() >= Duration::from_millis(10));
for _ in0..N { let jh = tokio::spawn(asyncmove { let now = Instant::now(); // timeout inside of the worker threads
tokio::time::timeout(Duration::from_millis(10), std::future::pending::<()>())
.await
.expect_err("timeout should occur");
assert!(now.elapsed() >= Duration::from_millis(10));
});
jhs.push(jh);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.