Skip to content

Conversation

@vdimir
Copy link
Contributor

@vdimir vdimir commented Oct 27, 2025

Ref #6277

@vdimir vdimir requested a review from a team as a code owner October 27, 2025 13:20
@vdimir vdimir requested review from fitzgen and removed request for a team October 27, 2025 13:20
@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Oct 27, 2025
Copy link
Member

@alexcrichton alexcrichton left a 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 =
Copy link
Member

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?

Comment on lines 15 to 20
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;
});
Copy link
Member

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?

Copy link
Contributor Author

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)?

Copy link
Member

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.

@vdimir vdimir changed the title Expose epoch_deadline_callback and raw_store in C++ api Expose epoch_deadline_callback in C++ api Oct 28, 2025
Comment on lines 15 to 20
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;
});
Copy link
Member

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.

@alexcrichton alexcrichton added this pull request to the merge queue Oct 29, 2025
Merged via the queue into bytecodealliance:main with commit 1f2feaf Oct 29, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants