component model: async host function & embedding support (#5055)

* func_wrap_async typechecks

* func call async

* instantiate_async

* fixes

* async engine creation for tests

* start adding a component model test for async

* fix wrong check for async support, factor out Instance::new_started to an unchecked impl

* tests: wibbles

* component::Linker::func_wrap: replace IntoComponentFunc with directly accepting a closure

We find that this makes the Linker::func_wrap type signature much easier
to read. The IntoComponentFunc abstraction was adding a lot of weight to
"splat" a set of arguments from a tuple of types into individual
arguments to the closure. Additionally, making the StoreContextMut
argument optional, or the Result<return> optional, wasn't very
worthwhile.

* Fixes for the new style of closure required by component::Linker::func_wrap

* future of result of return

* add Linker::instantiate_async and {Typed}Func::post_return_async

* fix fuzzing generator

* note optimisation opportunity

* simplify test
This commit is contained in:
Pat Hickey
2022-10-18 13:40:57 -07:00
committed by GitHub
parent 25bc12ec82
commit 12e4a1ba18
8 changed files with 351 additions and 17 deletions

View File

@@ -65,6 +65,12 @@ pub fn engine() -> Engine {
Engine::new(&config()).unwrap()
}
pub fn async_engine() -> Engine {
let mut config = config();
config.async_support(true);
Engine::new(&config).unwrap()
}
/// Newtype wrapper for `f32` whose `PartialEq` impl considers NaNs equal to each other.
#[derive(Copy, Clone, Debug, Arbitrary)]
pub struct Float32(pub f32);