summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/enter.rs
diff options
context:
space:
mode:
authorDan Burkert <dan@danburkert.com>2020-04-24 06:25:48 -0600
committerGitHub <noreply@github.com>2020-04-24 15:25:48 +0300
commitd8139fef7a555f99adaa37e139787d26e24daba3 (patch)
tree5695a5fc6560ca851d12da04464747d161c55790 /tokio/src/runtime/enter.rs
parent9bcb50660e2d9de26a4373aaf4ab8f324c8ebbe8 (diff)
Add Handle::block_on method (#2437)
Diffstat (limited to 'tokio/src/runtime/enter.rs')
-rw-r--r--tokio/src/runtime/enter.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/tokio/src/runtime/enter.rs b/tokio/src/runtime/enter.rs
index 9b3f2ad8..ad5580cc 100644
--- a/tokio/src/runtime/enter.rs
+++ b/tokio/src/runtime/enter.rs
@@ -138,14 +138,11 @@ cfg_rt_threaded! {
}
}
-cfg_blocking_impl! {
- use crate::park::ParkError;
- use std::time::Duration;
-
+cfg_block_on! {
impl Enter {
/// Blocks the thread on the specified future, returning the value with
/// which that future completes.
- pub(crate) fn block_on<F>(&mut self, mut f: F) -> Result<F::Output, ParkError>
+ pub(crate) fn block_on<F>(&mut self, mut f: F) -> Result<F::Output, crate::park::ParkError>
where
F: std::future::Future,
{
@@ -170,7 +167,14 @@ cfg_blocking_impl! {
park.park()?;
}
}
+ }
+}
+cfg_blocking_impl! {
+ use crate::park::ParkError;
+ use std::time::Duration;
+
+ impl Enter {
/// Blocks the thread on the specified future for **at most** `timeout`
///
/// If the future completes before `timeout`, the result is returned. If