Wasmtime
async.h
Go to the documentation of this file.
1
33#ifndef WASMTIME_ASYNC_H
34#define WASMTIME_ASYNC_H
35
36#include <wasm.h>
37#include <wasmtime/config.h>
38#include <wasmtime/error.h>
39#include <wasmtime/func.h>
40#include <wasmtime/linker.h>
41#include <wasmtime/store.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
59WASMTIME_CONFIG_PROP(void, async_support, bool)
60
61
79WASMTIME_CONFIG_PROP(void, async_stack_size, uint64_t)
80
97WASM_API_EXTERN wasmtime_error_t *
99 uint64_t interval);
100
111WASM_API_EXTERN wasmtime_error_t *
113 wasmtime_context_t *context, uint64_t delta);
114
122
130 void *env;
132 void (*finalizer)(void *);
134
162 void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args,
163 size_t nargs, wasmtime_val_t *results, size_t nresults,
164 wasm_trap_t **trap_ret, wasmtime_async_continuation_t *continuation_ret);
165
175typedef struct wasmtime_call_future wasmtime_call_future_t;
176
196
203WASM_API_EXTERN void
205
233 wasmtime_context_t *context, const wasmtime_func_t *func,
234 const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results,
235 size_t nresults, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
236
246 wasmtime_linker_t *linker, const char *module, size_t module_len,
247 const char *name, size_t name_len, const wasm_functype_t *ty,
248 wasmtime_func_async_callback_t cb, void *data, void (*finalizer)(void *));
249
266 const wasmtime_linker_t *linker, wasmtime_context_t *store,
267 const wasmtime_module_t *module, wasmtime_instance_t *instance,
268 wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
269
291 const wasmtime_instance_pre_t *instance_pre, wasmtime_context_t *store,
292 wasmtime_instance_t *instance, wasm_trap_t **trap_ret,
293 wasmtime_error_t **error_ret);
294
302typedef uint8_t *(*wasmtime_stack_memory_get_callback_t)(void *env,
303 size_t *out_len);
304
311typedef struct {
313 void *env;
317 void (*finalizer)(void *);
319
331typedef wasmtime_error_t *(*wasmtime_new_stack_memory_callback_t)(
332 void *env, size_t size, wasmtime_stack_memory_t *stack_ret);
333
340typedef struct {
342 void *env;
346 void (*finalizer)(void *);
348
361WASM_API_EXTERN void
364
365#ifdef __cplusplus
366} // extern "C"
367#endif
368
369#endif // WASMTIME_ASYNC_H
wasmtime_error_t *(* wasmtime_new_stack_memory_callback_t)(void *env, size_t size, wasmtime_stack_memory_t *stack_ret)
Definition: async.h:331
wasmtime_call_future_t * wasmtime_func_call_async(wasmtime_context_t *context, const wasmtime_func_t *func, const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results, size_t nresults, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret)
Invokes this function with the params given, returning the results asynchronously.
wasmtime_call_future_t * wasmtime_linker_instantiate_async(const wasmtime_linker_t *linker, wasmtime_context_t *store, const wasmtime_module_t *module, wasmtime_instance_t *instance, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret)
Instantiates a wasm_module_t with the items defined in this linker for an async store.
struct wasmtime_async_continuation_t wasmtime_async_continuation_t
void(* wasmtime_func_async_callback_t)(void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results, size_t nresults, wasm_trap_t **trap_ret, wasmtime_async_continuation_t *continuation_ret)
Callback signature for wasmtime_linker_define_async_func.
Definition: async.h:161
struct wasmtime_call_future wasmtime_call_future_t
The structure representing a asynchronously running function.
Definition: async.h:175
wasmtime_error_t * wasmtime_linker_define_async_func(wasmtime_linker_t *linker, const char *module, size_t module_len, const char *name, size_t name_len, const wasm_functype_t *ty, wasmtime_func_async_callback_t cb, void *data, void(*finalizer)(void *))
Defines a new async function in this linker.
wasmtime_error_t * wasmtime_context_epoch_deadline_async_yield_and_update(wasmtime_context_t *context, uint64_t delta)
Configures epoch-deadline expiration to yield to the async caller and the update the deadline.
void wasmtime_config_host_stack_creator_set(wasm_config_t *, wasmtime_stack_creator_t *)
void wasmtime_call_future_delete(wasmtime_call_future_t *future)
bool(* wasmtime_func_async_continuation_callback_t)(void *env)
Definition: async.h:121
bool wasmtime_call_future_poll(wasmtime_call_future_t *future)
Executes WebAssembly in the function.
uint8_t *(* wasmtime_stack_memory_get_callback_t)(void *env, size_t *out_len)
Definition: async.h:302
wasmtime_error_t * wasmtime_context_fuel_async_yield_interval(wasmtime_context_t *context, uint64_t interval)
Configures a Store to yield execution of async WebAssembly code periodically.
wasmtime_call_future_t * wasmtime_instance_pre_instantiate_async(const wasmtime_instance_pre_t *instance_pre, wasmtime_context_t *store, wasmtime_instance_t *instance, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret)
Instantiates instance within the given store.
Wasmtime-specific extensions to wasm_config_t.
Definition and accessors of wasmtime_error_t.
struct wasmtime_instance_pre wasmtime_instance_pre_t
A wasmtime_instance_t, pre-instantiation, that is ready to be instantiated.
Definition: instance.h:121
Global engine configuration.
An opaque object representing the type of a function.
Opaque struct representing a wasm trap.
Definition: async.h:126
wasmtime_func_async_continuation_callback_t callback
Callback for if the async function has completed.
Definition: async.h:128
void * env
User-provided argument to pass to the callback.
Definition: async.h:130
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
Errors generated by Wasmtime.
Representation of a function in Wasmtime.
Definition: extern.h:25
Representation of a instance in Wasmtime.
Definition: instance.h:26
Object used to conveniently link together and instantiate wasm modules.
A compiled Wasmtime module.
Definition: async.h:340
wasmtime_new_stack_memory_callback_t new_stack
The callback to create a new stack, must be thread safe.
Definition: async.h:344
void * env
User provided value to be passed to new_stack.
Definition: async.h:342
Definition: async.h:311
wasmtime_stack_memory_get_callback_t get_stack_memory
Callback to get the memory and size of this LinearMemory.
Definition: async.h:315
void * env
User provided value to be passed to get_memory and grow_memory.
Definition: async.h:313
Container for different kinds of wasm values.
Definition: val.h:441