Introduce async support
This is a massive change required to fix https://github.com/wapc/wapc-rs/issues/92
Changes to wapc crate
Allow waPC host to be used inside of an asynchronous runtime
New structs and traits have been added:
- New struct
WapcHostAsync, this is the equivalent ofWapcHostbut for async environments. - New trait
WebAssemblyEngineProviderAsync, this is the equivalent ofWebAssemblyEngineProviderbut for async environments. - New trait
ModuleHostAsync, this is the equivalent ofModuleHostbut for async environments.
An async runtime has an async host callback function. The new type alias HostCallbackAsync is used to define this function.
The signature of this function is slightly different from the one of the sync counterpart. All the input paremeters are owned types, not pointers. That's required because the function can be sent to different threads by the async runtime; introducing lifetime constraints proved to be impossible.
The async support is behind a feature flag named asyc. This flag is enabled by default.
The implementation relies on the tokio crate.
Other notable changes:
- The
synccode has been moved to dedicated files to separate it from theasynccode. - The documentation now states which feature flags might be required to use a struct, type, trait, or method.
Changes to wasmtime-provider crate
New structs and traits have been added:
- New struct
WasmtimeEngineProviderAsync, this is the equivalent ofWasmtimeEngineProviderbut for async environments. - New struct
WasmtimeEngineProviderAsyncPre, this is the equivalent ofWasmtimeEngineProviderPrebut for async environments. - The
WasmtimeEngineProviderBuilderhas been extened to allow the creation of the new "async" objects describe above.
The async support is behind a feature flag named asyc. This flag is enabled by default. The implementation relies on the tokio crate.
Other notable changes:
- The
synccode has been moved to dedicated files to separate it from theasynccode. - The documentation now states which feature flags might be required to use a struct, type, trait, or method.
- New and improved tests
- Reorganized the examples, new ones have been introduced for the async counterparts
- Improved
make testtarget to cover all the different combination of feature flags - Fix compilation errors caused by different flag combinations
Once merged, we will have to tag new release of wapc and wasmtime-provider. I wonder if we should do a major release instead of a minor one.
Ideas?
Thanks for get awesome description! I agree this probably warrants a new major release. I'm a little busy but I will review this as soon.
@pkedy, did you have chance to look at the PR? :pray:
@pkedy can you please take a look at the PR? :pray:
I've rebased the PR against the latest changed that landed into the master branch. I'll merge it once everything is green
wasmtime-provider 2.0.0 and wapc 2.0.0 are now available on crates.io 🥳