You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
507 B

Async support in the C API (#7106) * c-api: Add a feature for async Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Add support for async config Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Add support for calling async functions Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Add ability to yield execution of Wasm in a store Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Introduce wasmtime_linker_instantiate_async Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Support defining async host functions Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * gitignore: ignore cmake cache for examples Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * examples: Add example of async API in C Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Consolidate async functionality into a single place Put all the async stuff in it's own header and own rust source file Also remove the wasmtime_async_continuation_new function, users can just allocate it directly. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Make async function safe Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Remove wasmtime_call_future_get_results Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Simplify CHostCallFuture Move the result translation and hostcall_val_storage usage into an async function Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Simplify C continuation implementation Remove the caller, which means that we don't need another struct for the future implementation. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Improve async.h documentation Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Cleanup from previous changes Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * examples: Fix example Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Simplify continuation callback This gives more duality with calling an async function and also means that the implementation can pretty much mirror the sync version. Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Fix async.h documentation Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Fix documentation for async.h Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: Review feedback Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * examples: Downgrade async.cpp example to C++11 Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * c-api: initialize continuation with a panic callback Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> * prtest:full Signed-off-by: Tyler Rockwood <rockwood@redpanda.com> --------- Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
1 year ago
(module
(import "host" "print" (func $print (param i32)))
(func $fibonacci (param $n i32) (result i32)
(if
(i32.lt_s (local.get $n) (i32.const 2))
(then (return (local.get $n)))
)
(i32.add
(call $fibonacci (i32.sub (local.get $n) (i32.const 1)))
(call $fibonacci (i32.sub (local.get $n) (i32.const 2)))
)
)
(func $print_fibonacci (param $n i32)
(call $fibonacci (local.get $n))
(call $print)
)
(export "print_fibonacci" (func $print_fibonacci))
)