@@ -200,19 +200,44 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_context_set_wasi(wasmtime_context_t *
200200 */
201201WASM_API_EXTERN void wasmtime_context_set_epoch_deadline (wasmtime_context_t * context , uint64_t ticks_beyond_current );
202202
203+ // \brief An enum for the behavior before extending the epoch deadline.
204+ typedef wasmtime_update_deadline_kind_t uint8_t ;
205+ // \brief Directly continue to updating the deadline and executing WebAssembly.
206+ #define WASMTIME_UPDATE_DEADLINE_CONTINUE 0
207+ // \brief Yield control (via async support) then update the deadline.
208+ #define WASMTIME_UPDATE_DEADLINE_YIELD 1
209+
203210/**
204211 * \brief Configures epoch deadline callback to C function.
205212 *
206213 * This function configures a store-local callback function that will be
207214 * called when the running WebAssembly function has exceeded its epoch
208- * deadline. That function can return a #wasmtime_error_t to terminate
209- * the function, or set the delta argument and return NULL to update the
210- * epoch deadline and resume function execution.
215+ * deadline. That function can:
216+ * - return a #wasmtime_error_t to terminate the function
217+ * - set the delta argument and return NULL to update the
218+ * epoch deadline delta and resume function execution.
219+ * - set the delta argument, update the epoch deadline,
220+ * set update_kind to WASMTIME_UPDATE_DEADLINE_YIELD,
221+ * and return NULL to yield (via async support) and
222+ * resume function execution.
223+ *
224+ * To use WASMTIME_UPDATE_DEADLINE_YIELD async support must be enabled
225+ * for this store.
211226 *
212227 * See also #wasmtime_config_epoch_interruption_set and
213228 * #wasmtime_context_set_epoch_deadline.
214229 */
215- WASM_API_EXTERN void wasmtime_store_epoch_deadline_callback (wasmtime_store_t * store , wasmtime_error_t * (* func )(wasmtime_context_t * , void * , uint64_t * ), void * data );
230+ WASM_API_EXTERN void wasmtime_store_epoch_deadline_callback (
231+ wasmtime_store_t * store ,
232+ wasmtime_error_t * (* func )(
233+ wasmtime_context_t * context ,
234+ void * data ,
235+ uint64_t * epoch_deadline_delta ,
236+ wasmtime_update_deadline_kind_t * update_kind
237+ ),
238+ void * data ,
239+ void (* finalizer )(void * )
240+ );
216241
217242#ifdef __cplusplus
218243} // extern "C"
0 commit comments