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/conf.h>
38#include <wasmtime/config.h>
39#include <wasmtime/error.h>
40#include <wasmtime/func.h>
41#include <wasmtime/linker.h>
42#include <wasmtime/store.h>
43
44#ifdef WASMTIME_FEATURE_ASYNC
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
62WASMTIME_CONFIG_PROP(void, async_support, bool)
63
64
82WASMTIME_CONFIG_PROP(void, async_stack_size, uint64_t)
83
100WASM_API_EXTERN wasmtime_error_t *
102 uint64_t interval);
103
114WASM_API_EXTERN wasmtime_error_t *
116 wasmtime_context_t *context, uint64_t delta);
117
125
133 void *env;
135 void (*finalizer)(void *);
137
165 void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args,
166 size_t nargs, wasmtime_val_t *results, size_t nresults,
167 wasm_trap_t **trap_ret, wasmtime_async_continuation_t *continuation_ret);
168
178typedef struct wasmtime_call_future wasmtime_call_future_t;
179
199
206WASM_API_EXTERN void
208
236 wasmtime_context_t *context, const wasmtime_func_t *func,
237 const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results,
238 size_t nresults, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
239
249 wasmtime_linker_t *linker, const char *module, size_t module_len,
250 const char *name, size_t name_len, const wasm_functype_t *ty,
251 wasmtime_func_async_callback_t cb, void *data, void (*finalizer)(void *));
252
269 const wasmtime_linker_t *linker, wasmtime_context_t *store,
270 const wasmtime_module_t *module, wasmtime_instance_t *instance,
271 wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
272
294 const wasmtime_instance_pre_t *instance_pre, wasmtime_context_t *store,
295 wasmtime_instance_t *instance, wasm_trap_t **trap_ret,
296 wasmtime_error_t **error_ret);
297
305typedef uint8_t *(*wasmtime_stack_memory_get_callback_t)(void *env,
306 size_t *out_len);
307
314typedef struct {
316 void *env;
320 void (*finalizer)(void *);
322
334typedef wasmtime_error_t *(*wasmtime_new_stack_memory_callback_t)(
335 void *env, size_t size, wasmtime_stack_memory_t *stack_ret);
336
343typedef struct {
345 void *env;
349 void (*finalizer)(void *);
351
364WASM_API_EXTERN void
367
368#ifdef __cplusplus
369} // extern "C"
370#endif
371
372#endif // WASMTIME_FEATURE_ASYNC
373
374#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:334
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:164
struct wasmtime_call_future wasmtime_call_future_t
The structure representing a asynchronously running function.
Definition: async.h:178
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:124
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:305
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.
Build-time defines for how the C API was built.
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:129
wasmtime_func_async_continuation_callback_t callback
Callback for if the async function has completed.
Definition: async.h:131
void * env
User-provided argument to pass to the callback.
Definition: async.h:133
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:343
wasmtime_new_stack_memory_callback_t new_stack
The callback to create a new stack, must be thread safe.
Definition: async.h:347
void * env
User provided value to be passed to new_stack.
Definition: async.h:345
Definition: async.h:314
wasmtime_stack_memory_get_callback_t get_stack_memory
Callback to get the memory and size of this LinearMemory.
Definition: async.h:318
void * env
User provided value to be passed to get_memory and grow_memory.
Definition: async.h:316
Container for different kinds of wasm values.
Definition: val.h:441