#ifndef WASMTIME_ASYNC_H
#define WASMTIME_ASYNC_H
#include <wasm.h>
#include <wasmtime/config.h>
#include <wasmtime/error.h>
#include <wasmtime/func.h>
#include <wasmtime/linker.h>
#include <wasmtime/store.h>
#ifdef __cplusplus
extern "C" {
#endif
WASMTIME_CONFIG_PROP(void, async_support, bool)
WASMTIME_CONFIG_PROP(void, async_stack_size, uint64_t)
WASM_API_EXTERN wasmtime_error_t *
wasmtime_context_fuel_async_yield_interval(wasmtime_context_t *context,
uint64_t interval);
WASM_API_EXTERN wasmtime_error_t *
wasmtime_context_epoch_deadline_async_yield_and_update(
wasmtime_context_t *context, uint64_t delta);
typedef bool (*wasmtime_func_async_continuation_callback_t)(void *env);
typedef struct wasmtime_async_continuation_t {
wasmtime_func_async_continuation_callback_t callback;
void *env;
void (*finalizer)(void *);
} wasmtime_async_continuation_t;
typedef 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);
typedef struct wasmtime_call_future wasmtime_call_future_t;
WASM_API_EXTERN bool wasmtime_call_future_poll(wasmtime_call_future_t *future);
WASM_API_EXTERN void
wasmtime_call_future_delete(wasmtime_call_future_t *future);
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);
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 *));
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);
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);
typedef uint8_t *(*wasmtime_stack_memory_get_callback_t)(void *env,
size_t *out_len);
typedef struct {
void *env;
wasmtime_stack_memory_get_callback_t get_stack_memory;
void (*finalizer)(void *);
} wasmtime_stack_memory_t;
typedef wasmtime_error_t *(*wasmtime_new_stack_memory_callback_t)(
void *env, size_t size, wasmtime_stack_memory_t *stack_ret);
typedef struct {
void *env;
wasmtime_new_stack_memory_callback_t new_stack;
void (*finalizer)(void *);
} wasmtime_stack_creator_t;
WASM_API_EXTERN void
wasmtime_config_host_stack_creator_set(wasm_config_t *,
wasmtime_stack_creator_t *);
#ifdef __cplusplus
} #endif
#endif