(f: impl Future<Output = T>)
| 6 | /// This function blocks on a future in place until it is ready. |
| 7 | #[cfg(feature = "std")] |
| 8 | pub fn block_on<T>(f: impl Future<Output = T>) -> T { |
| 9 | // When running with Tokio, use the appropriate blocking mechanism |
| 10 | if let Ok(runtime) = tokio::runtime::Handle::try_current() { |
| 11 | tokio::task::block_in_place(|| runtime.block_on(f)) |
| 12 | } else { |
| 13 | // Fallback to tokio's block_on if we're not in a runtime |
| 14 | tokio::runtime::Runtime::new().unwrap().block_on(f) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /// This function busy waits on a future until it is ready. It uses a no-op waker to poll the future |
| 19 | /// in a thread-blocking loop. |
no test coverage detected