-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Run a callback when the interruption epoch is reached #4152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run a callback when the interruption epoch is reached #4152
Conversation
Adds Store::epoch_deadline_callback. This accepts a callback which, when invoked, can mutate the store's contents. The callback can either return an error (in which case we trap) or return a delta which we'll use to set the new epoch deadline.
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks! Could you add a test which also returns a trap from the closure? Finally could you also add a test which specifically uses this function and asserts that the callback was indeed called? (e.g. frobs the state on T
or something like that)
- Remove use of &mut in the pattern match - Return both yields and state from run_and_count_yields_or_trap in test code and assert on them separately. - Add a test for trapping on a state failure.
Thank you so much! |
Adds Store::epoch_deadline_callback. This accepts a callback which, when invoked, can mutate the store's contents. The callback can either return an error (in which case we trap) or return a delta which we'll use to set the new epoch deadline.
As discussed with @alexcrichton on Zulip. I'm not very happy with the tests here - happy to improve those if people have ideas.
It might be desirable to reimplement the trap and yield behaviours in terms of this callback. Happy to do that if preferred.