wasmtime_store_epoch_deadline_callback function

  1. @Native<Void Function(Pointer<wasmtime_store_t>, Pointer<NativeFunction<Pointer<wasmtime_error_t> Function(Pointer<wasmtime_context_t> context, Pointer<Void> data, Pointer<Uint64> epoch_deadline_delta, Pointer<Uint8> update_kind)>>, Pointer<Void>, Pointer<NativeFunction<Void Function(Pointer<Void>)>>)>(ffi.Pointer<wasmtime_store_t>, ffi.Pointer<ffi.NativeFunction<ffi.Pointer<wasmtime_error_t> Function(ffi.Pointer<wasmtime_context_t> context, ffi.Pointer<ffi.Void> data, ffi.Pointer<ffi.Uint64> epoch_deadline_delta, ffi.Pointer<wasmtime_update_deadline_kind_t> update_kind)>>, ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>)>()
void wasmtime_store_epoch_deadline_callback(
  1. Pointer<wasmtime_store_t> store,
  2. Pointer<NativeFunction<Pointer<wasmtime_error_t> Function(Pointer<wasmtime_context_t> context, Pointer<Void> data, Pointer<Uint64> epoch_deadline_delta, Pointer<Uint8> update_kind)>> func,
  3. Pointer<Void> data,
  4. Pointer<NativeFunction<Void Function(Pointer<Void>)>> finalizer,
)

\brief Configures epoch deadline callback to C function.

This function configures a store-local callback function that will be called when the running WebAssembly function has exceeded its epoch deadline. That function can:

  • return a #wasmtime_error_t to terminate the function
  • set the delta argument and return NULL to update the epoch deadline delta and resume function execution.
  • set the delta argument, update the epoch deadline, set update_kind to WASMTIME_UPDATE_DEADLINE_YIELD, and return NULL to yield (via async support) and resume function execution.

To use WASMTIME_UPDATE_DEADLINE_YIELD async support must be enabled for this store.

See also #wasmtime_config_epoch_interruption_set and #wasmtime_context_set_epoch_deadline.

Implementation

@ffi.Native<
  ffi.Void Function(
    ffi.Pointer<wasmtime_store_t>,
    ffi.Pointer<
      ffi.NativeFunction<
        ffi.Pointer<wasmtime_error_t> Function(
          ffi.Pointer<wasmtime_context_t> context,
          ffi.Pointer<ffi.Void> data,
          ffi.Pointer<ffi.Uint64> epoch_deadline_delta,
          ffi.Pointer<wasmtime_update_deadline_kind_t> update_kind,
        )
      >
    >,
    ffi.Pointer<ffi.Void>,
    ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>,
  )
>()
external void wasmtime_store_epoch_deadline_callback(
  ffi.Pointer<wasmtime_store_t> store,
  ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<wasmtime_error_t> Function(
        ffi.Pointer<wasmtime_context_t> context,
        ffi.Pointer<ffi.Void> data,
        ffi.Pointer<ffi.Uint64> epoch_deadline_delta,
        ffi.Pointer<wasmtime_update_deadline_kind_t> update_kind,
      )
    >
  >
  func,
  ffi.Pointer<ffi.Void> data,
  ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>
  finalizer,
);