Skip to content

Commit c0216a1

Browse files
committed
Review comments
1 parent 04f4253 commit c0216a1

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

crates/guest-rust/rt/src/async_support/cabi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
//! `std::future::Future`.
1313
//!
1414
//! Without this module this situation won't work because 0.A.0 has no
15-
//! knowledge of 0.B.0 meaning that when 0.B.0 decides to block it won't know
16-
//! where to register its `waitable` within a `waitable-set`.
15+
//! knowledge of 0.B.0 meaning that 0.B.0 has no means of inserting a `waitable`
16+
//! into the `waitable-set` managed by 0.A.0's export.
1717
//!
1818
//! To solve this problem the long-term intention is that something will live
1919
//! in `wasi-libc` itself, but in the meantime it's living "somewhere" within
20-
//! `wit-bindgen 0.*.0`. Specifically all `wit-bindgen` versions will all
20+
//! `wit-bindgen 0.*.0`. Specifically all `wit-bindgen` versions will
2121
//! reference, via C linkage, a single function which is used to manipulate a
2222
//! single pointer in linear memory. This pointer is a `wasip3_task` structure
2323
//! which has all the various fields to use it.
@@ -50,7 +50,7 @@ extern "C" {
5050
/// Sets the global task pointer to `ptr` provided. Returns the previous
5151
/// value.
5252
///
53-
/// This function acts as both a dual getter and a setter. To get the
53+
/// This function acts as a dual getter and a setter. To get the
5454
/// current task pointer a dummy `ptr` can be provided (e.g. NULL) and then
5555
/// it's passed back when you're done working with it. When setting the
5656
/// current task pointer it's recommended to call this and then call it
@@ -85,7 +85,7 @@ pub struct wasip3_task {
8585
/// well as the `callback_ptr` provided.
8686
///
8787
/// If `waitable` was previously registered with this task then the
88-
/// previuos `callback_ptr` is returned. Otherwise `NULL` is returned.
88+
/// previous `callback_ptr` is returned. Otherwise `NULL` is returned.
8989
///
9090
/// It's the caller's responsibility to ensure that `callback_ptr` is valid
9191
/// until `callback` is invoked, `waitable_unregister` is invoked, or

crates/guest-rust/rt/src/async_support/waitable.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ where
206206
// double-check it's initialized and additionally check the version for
207207
// the fields that we access.
208208
//
209-
// Otherwise the `waitable_unregister` callback should be safe if we
210-
// pass a waitable that we own and the task's own pointer.
209+
// Otherwise the `waitable_unregister` callback should be safe because:
210+
//
211+
// * We're fulfilling the contract where the first argument must be
212+
// `(*task).ptr`
213+
// * We own the `waitable` that we're passing in, so we're fulfilling
214+
// the contract that arbitrary waitables for other units of work
215+
// aren't being manipulated.
211216
unsafe {
212217
let task = cabi::wasip3_task_set(ptr::null_mut());
213218
assert!(!task.is_null());

0 commit comments

Comments
 (0)