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
68WASMTIME_CONFIG_PROP(void, async_stack_size, uint64_t)
69
70
86WASM_API_EXTERN wasmtime_error_t *
88 uint64_t interval);
89
100WASM_API_EXTERN wasmtime_error_t *
102 wasmtime_context_t *context, uint64_t delta);
103
111
119 void *env;
121 void (*finalizer)(void *);
123
151 void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args,
152 size_t nargs, wasmtime_val_t *results, size_t nresults,
153 wasm_trap_t **trap_ret, wasmtime_async_continuation_t *continuation_ret);
154
164typedef struct wasmtime_call_future wasmtime_call_future_t;
165
185
192WASM_API_EXTERN void
194
222 wasmtime_context_t *context, const wasmtime_func_t *func,
223 const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results,
224 size_t nresults, wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
225
235 wasmtime_linker_t *linker, const char *module, size_t module_len,
236 const char *name, size_t name_len, const wasm_functype_t *ty,
237 wasmtime_func_async_callback_t cb, void *data, void (*finalizer)(void *));
238
255 const wasmtime_linker_t *linker, wasmtime_context_t *store,
256 const wasmtime_module_t *module, wasmtime_instance_t *instance,
257 wasm_trap_t **trap_ret, wasmtime_error_t **error_ret);
258
280 const wasmtime_instance_pre_t *instance_pre, wasmtime_context_t *store,
281 wasmtime_instance_t *instance, wasm_trap_t **trap_ret,
282 wasmtime_error_t **error_ret);
283
291typedef uint8_t *(*wasmtime_stack_memory_get_callback_t)(void *env,
292 size_t *out_len);
293
300typedef struct {
302 void *env;
306 void (*finalizer)(void *);
308
320typedef wasmtime_error_t *(*wasmtime_new_stack_memory_callback_t)(
321 void *env, size_t size, bool zeroed, wasmtime_stack_memory_t *stack_ret);
322
329typedef struct {
331 void *env;
335 void (*finalizer)(void *);
337
350WASM_API_EXTERN void
353
354#ifdef __cplusplus
355} // extern "C"
356#endif
357
358#endif // WASMTIME_FEATURE_ASYNC
359
360#endif // WASMTIME_ASYNC_H
WASM_API_EXTERN 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.
WASM_API_EXTERN void wasmtime_call_future_delete(wasmtime_call_future_t *future)
wasmtime_error_t *(* wasmtime_new_stack_memory_callback_t)(void *env, size_t size, bool zeroed, wasmtime_stack_memory_t *stack_ret)
Definition: async.h:320
WASM_API_EXTERN bool wasmtime_call_future_poll(wasmtime_call_future_t *future)
Executes WebAssembly in the function.
WASM_API_EXTERN 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.
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:150
struct wasmtime_call_future wasmtime_call_future_t
The structure representing a asynchronously running function.
Definition: async.h:164
WASM_API_EXTERN 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.
WASM_API_EXTERN wasmtime_error_t * wasmtime_context_fuel_async_yield_interval(wasmtime_context_t *context, uint64_t interval)
Configures the size of the stacks used for asynchronous execution.
WASM_API_EXTERN 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.
WASM_API_EXTERN 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.
WASM_API_EXTERN void wasmtime_config_host_stack_creator_set(wasm_config_t *, wasmtime_stack_creator_t *)
bool(* wasmtime_func_async_continuation_callback_t)(void *env)
Definition: async.h:110
uint8_t *(* wasmtime_stack_memory_get_callback_t)(void *env, size_t *out_len)
Definition: async.h:291
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:115
wasmtime_func_async_continuation_callback_t callback
Callback for if the async function has completed.
Definition: async.h:117
void(* finalizer)(void *)
A finalizer for the user-provided *env.
Definition: async.h:121
void * env
User-provided argument to pass to the callback.
Definition: async.h:119
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:329
wasmtime_new_stack_memory_callback_t new_stack
The callback to create a new stack, must be thread safe.
Definition: async.h:333
void * env
User provided value to be passed to new_stack.
Definition: async.h:331
Definition: async.h:300
wasmtime_stack_memory_get_callback_t get_stack_memory
Callback to get the memory and size of this LinearMemory.
Definition: async.h:304
void * env
User provided value to be passed to get_memory and grow_memory.
Definition: async.h:302
Container for different kinds of wasm values.
Definition: val.h:456