Add an API to terminate instance (#2538)
Add API wasm_runtime_terminate to terminate a module instance by setting "terminated by user" exception to the module instance. And update the product-mini of posix platforms. Note: this doesn't work for some situations like blocking system calls.
This commit is contained in:
@ -894,6 +894,27 @@ wasm_runtime_set_exception(wasm_module_inst_t module_inst,
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_clear_exception(wasm_module_inst_t module_inst);
|
||||
|
||||
/**
|
||||
* Terminate the WASM module instance.
|
||||
*
|
||||
* This function causes the module instance fail as if it raised a trap.
|
||||
*
|
||||
* This is intended to be used in situations like:
|
||||
*
|
||||
* - A thread is executing the WASM module instance
|
||||
* (eg. it's in the middle of `wasm_application_execute_main`)
|
||||
*
|
||||
* - Another thread has a copy of `wasm_module_inst_t` of
|
||||
* the module instance and wants to terminate it asynchronously.
|
||||
*
|
||||
* This function is provided only when WAMR is built with threading enabled.
|
||||
* (`WASM_ENABLE_THREAD_MGR=1`)
|
||||
*
|
||||
* @param module_inst the WASM module instance
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_terminate(wasm_module_inst_t module_inst);
|
||||
|
||||
/**
|
||||
* Set custom data to WASM module instance.
|
||||
* Note:
|
||||
|
||||
Reference in New Issue
Block a user