async-await: add current_thread::Runtime::block_on_async (#1072)

This function is used by the Tokio macros introduced by #1058  but was
omitted from the PR.
This commit is contained in:
Carl Lerche
2019-04-30 19:55:22 -07:00
committed by GitHub
parent 219f24cbf1
commit 4ef736b9d5
8 changed files with 73 additions and 15 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ tokio-codec = { path = "../tokio-codec" }
tokio-current-thread = { path = "../tokio-current-thread" }
tokio-executor = { path = "../tokio-executor" }
tokio-fs = { path = "../tokio-fs" }
# tokio-futures = { path = "../" }
tokio-futures = { path = "../tokio-futures" }
tokio-io = { path = "../tokio-io" }
tokio-reactor = { path = "../tokio-reactor" }
tokio-signal = { path = "../tokio-signal" }
+22
View File
@@ -0,0 +1,22 @@
#![feature(await_macro, async_await)]
use tokio::await;
use tokio::timer::Delay;
use std::time::{Duration, Instant};
#[tokio::test]
async fn success_no_async() {
assert!(true);
}
#[tokio::test]
#[should_panic]
async fn fail_no_async() {
assert!(false);
}
#[tokio::test]
async fn use_timer() {
let when = Instant::now() + Duration::from_millis(10);
await!(Delay::new(when));
}