Runs a future on the current runtime, or creates one when needed.
(f: impl Future<Output = T>)
| 1218 | |
| 1219 | /// Runs a future on the current runtime, or creates one when needed. |
| 1220 | pub fn block_on<T>(f: impl Future<Output = T>) -> T { |
| 1221 | if let Ok(runtime) = tokio::runtime::Handle::try_current() { |
| 1222 | tokio::task::block_in_place(|| runtime.block_on(f)) |
| 1223 | } else { |
| 1224 | tokio::runtime::Runtime::new().unwrap().block_on(f) |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | /// Base-specific discovery configuration. |