Support function execution timeout within a sandbox
Motivation
We use WASM to support our Cloud Function to be executed in the WASM sandbox. Our cloud function supports a feature to specify number of seconds in timeout when invoking the function. For example, if we set 'timeout=3‘ , it indicates the given function will be invoked in a newly created sandbox within 3 seconds, if 3-second timeout reaches, a proper error message to return to the client and the sandbox will be properly shutdown.
Details
During the creation of a sandbox to run a function, we would like WASM runtime to allow taking a "timeout" parameter when a sandbox is initialized, when the function was executed in the sandbox, it observes the time of execution of this function is over the specified "timeout" value, an error is returned and the sandbox will be properly shutdown.