Open ActivePeter opened 1 year ago
How to implement the concurrency through wasm?
each task spawn a VM Instance?
In most cases, a VM Instance includes both wasm and the host module. The execution of wasm often changes the state of the host module. If you ensure that your host module is reusable, you can retain this VM Instance after wasm execution, then register new wasm into it for subsequent runs. Otherwise, it's better to create a new VM instance each time.
The VM instance cannot simultaneously run multiple function tasks; it can execute multiple function tasks sequentially. This is because, during the execution of wasm, changes to some data in the VM may occur through host functions. Therefore, a function, while executing, requires a mutable reference to the VM.