Re: [PATCH v2 3/4] rust: completion: add complete()
From: Maurice Hieronymus
Date: Thu Jul 02 2026 - 10:17:30 EST
On Sat Jun 20, 2026 at 11:48 AM CEST, Onur Özkan wrote:
>>
>> + /// Signal a single task waiting on this completion.
>> + ///
>> + /// This method wakes up a single task waiting on this completion.
>> + /// If no task is currently waiting, the next
>> + /// [`Completion::wait_for_completion`] returns immediately.
>> + #[inline]
>> + pub fn complete(&self) {
>> + // SAFETY: `self.as_raw()` is a pointer to a valid `struct completion`.
>
> I think the safety comment is a bit weak here. It would be nice to add why
> self.as_raw() is guaranteed to be a valid pointer.
>
I agree with you. However, I just copied the safety comment from the other functions.
That being said, should I also change the saftey comments of all the other functions then?
I thought something along those lines:
// SAFETY: `self.as_raw()` points to `self.inner`, a `struct completion` initialized by
// `Completion::new()` (the only constructor) and kept alive by the `&self` borrow.
Best,
Maurice
> - Onur
>
>> + unsafe { bindings::complete(self.as_raw()) };
>> + }
>> +
>> /// Signal all tasks waiting on this completion.
>> ///
>> /// This method wakes up all tasks waiting on this completion; after this operation the
>>
>> --
>> 2.51.2
>>