Runs a future on the current runtime, or creates one when needed.
(f: impl Future<Output = T>)
| 1090 | |
| 1091 | /// Runs a future on the current runtime, or creates one when needed. |
| 1092 | pub fn block_on<T>(f: impl Future<Output = T>) -> T { |
| 1093 | if let Ok(runtime) = tokio::runtime::Handle::try_current() { |
| 1094 | tokio::task::block_in_place(|| runtime.block_on(f)) |
| 1095 | } else { |
| 1096 | tokio::runtime::Runtime::new().unwrap().block_on(f) |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | /// Base-specific discovery configuration. |
no outgoing calls