Runs a future on the current runtime, or creates one when needed.
(f: impl Future<Output = T>)
| 1167 | |
| 1168 | /// Runs a future on the current runtime, or creates one when needed. |
| 1169 | pub fn block_on<T>(f: impl Future<Output = T>) -> T { |
| 1170 | if let Ok(runtime) = tokio::runtime::Handle::try_current() { |
| 1171 | tokio::task::block_in_place(|| runtime.block_on(f)) |
| 1172 | } else { |
| 1173 | tokio::runtime::Runtime::new().unwrap().block_on(f) |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /// Base-specific discovery configuration. |
no outgoing calls