-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expose epoch_deadline_callback in C++ api #11945
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
Expose epoch_deadline_callback in C++ api #11945
Conversation
alexcrichton
left a comment
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.
Thanks for this!
| if (!result) { | ||
| return result.err().release(); | ||
| } | ||
| *epoch_deadline_delta = |
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.
s/epoch_deadline_delta/update_kind/ I believe?
| store.epoch_deadline_callback( | ||
| [](wasmtime::Store::Context /* context */, uint64_t &epoch_deadline_delta) | ||
| -> wasmtime::Result<wasmtime::DeadlineKind> { | ||
| epoch_deadline_delta += 1; | ||
| return wasmtime::DeadlineKind::Continue; | ||
| }); |
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.
To help catch the above bug, would you be up for expanding the test her to run the callback as well?
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.
By the way, is there any reason why we should do epoch_deadline_delta += 1 in the callback instead of context.set_epoch_deadline(1) (the second does not work in the newly added test)?
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.
I believe it mostly mirrors the Rust-side API here. Other than that though no particular reasons, you're right that the Rust side could use the store to update the dealine and then return continue/yield as an enum.
| store.epoch_deadline_callback( | ||
| [](wasmtime::Store::Context /* context */, uint64_t &epoch_deadline_delta) | ||
| -> wasmtime::Result<wasmtime::DeadlineKind> { | ||
| epoch_deadline_delta += 1; | ||
| return wasmtime::DeadlineKind::Continue; | ||
| }); |
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.
I believe it mostly mirrors the Rust-side API here. Other than that though no particular reasons, you're right that the Rust side could use the store to update the dealine and then return continue/yield as an enum.
Ref #6277