(
engine: &Engine,
ty: FuncType,
ctx: U,
func: F,
)
| 2308 | /// captured in the closures generated here. |
| 2309 | #[cfg(feature = "async")] |
| 2310 | fn vmctx_async<F, T, U>( |
| 2311 | engine: &Engine, |
| 2312 | ty: FuncType, |
| 2313 | ctx: U, |
| 2314 | func: F, |
| 2315 | ) -> Result<StoreBox<VMArrayCallHostFuncContext>, OutOfMemory> |
| 2316 | where |
| 2317 | F: for<'a> Fn( |
| 2318 | Caller<'a, T>, |
| 2319 | &'a mut [MaybeUninit<ValRaw>], |
| 2320 | &'a U, |
| 2321 | ) -> Box<dyn Future<Output = Result<()>> + Send + 'a> |
| 2322 | + Send |
| 2323 | + Sync |
| 2324 | + 'static, |
| 2325 | T: 'static, |
| 2326 | U: Send + Sync + 'static, |
| 2327 | { |
| 2328 | // Eventually we want to remove `with_blocking` + `block_on` from |
| 2329 | // Wasmtime. For now this is the attempt to keep it as low-level as |
| 2330 | // possible. |
| 2331 | // |
| 2332 | // Generally it's a lie to run async things on top of sync things and |
| 2333 | // it's caused many headaches. For now it's the best that can be done. |
| 2334 | Self::vmctx_sync(engine, ty, move |Caller { store, caller }, args| { |
| 2335 | store.with_blocking(|store, cx| { |
| 2336 | cx.block_on(core::pin::Pin::from(func( |
| 2337 | Caller { store, caller }, |
| 2338 | args, |
| 2339 | &ctx, |
| 2340 | ))) |
| 2341 | })? |
| 2342 | }) |
| 2343 | } |
| 2344 | |
| 2345 | /// Entrypoint of WebAssembly back into the host. |
| 2346 | /// |
nothing calls this directly
no test coverage detected