time: introduce sleep and sleep_until functions (#2826)

This commit is contained in:
Juan Alvarez
2020-10-01 09:24:33 +02:00
committed by GitHub
parent 971ed2c6df
commit 53ccfc1fd6
31 changed files with 152 additions and 153 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ fn timer_with_threaded_runtime() {
rt.spawn(async move {
let when = Instant::now() + Duration::from_millis(100);
delay_until(when).await;
sleep_until(when).await;
assert!(Instant::now() >= when);
tx.send(()).unwrap();
@@ -38,7 +38,7 @@ fn timer_with_basic_scheduler() {
rt.block_on(async move {
let when = Instant::now() + Duration::from_millis(100);
delay_until(when).await;
sleep_until(when).await;
assert!(Instant::now() >= when);
tx.send(()).unwrap();
@@ -72,7 +72,7 @@ async fn starving() {
}
let when = Instant::now() + Duration::from_millis(20);
let starve = Starve(delay_until(when), 0);
let starve = Starve(sleep_until(when), 0);
starve.await;
assert!(Instant::now() >= when);