summaryrefslogtreecommitdiffstats
path: root/tokio-test
diff options
context:
space:
mode:
authorKevin Leimkuhler <kleimkuhler@icloud.com>2019-11-20 12:24:41 -0800
committerCarl Lerche <me@carllerche.com>2019-11-20 12:24:41 -0800
commit3e643c7b81736a4c2b11387a6f71aba99450270b (patch)
tree2be18c72374efcf8716c3a7d90783027231f909a /tokio-test
parentbc150cd0b56cf6dcb7c4feab64e83b9938faa186 (diff)
time: Eagerly bind delays to timer (#1800)
## Motivation Similar to #1666, it is no longer necessary to lazily register delays with the executions default timer. All delays are expected to be created from within a runtime, and should panic if not done so. ## Solution `tokio::time` now assumes there to be a `CURRENT_TIMER` set when creating a delay; this can be assumed if called within a tokio runtime. If there is no current timer, the application will panic with a "no current timer" message. ## Follow-up Similar to #1666, `HandlePriv` can probably be removed, but this mainly prepares for 0.2 API changes. Because it is not in the public API, this can be done in a following change. Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Diffstat (limited to 'tokio-test')
-rw-r--r--tokio-test/tests/block_on.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/tokio-test/tests/block_on.rs b/tokio-test/tests/block_on.rs
index b50f9ae1..7aec82cc 100644
--- a/tokio-test/tests/block_on.rs
+++ b/tokio-test/tests/block_on.rs
@@ -20,5 +20,10 @@ fn async_fn() {
#[test]
fn test_delay() {
let deadline = Instant::now() + Duration::from_millis(100);
- assert_eq!((), block_on(delay_until(deadline)));
+ assert_eq!(
+ (),
+ block_on(async {
+ delay_until(deadline).await;
+ })
+ );
}