Re: [PATCH v4 1/3] rust: Add `OnceLite` for executing code once

From: Alice Ryhl
Date: Wed Nov 27 2024 - 07:27:14 EST


On Tue, Nov 26, 2024 at 5:41 PM Jens Korinth via B4 Relay
<devnull+jens.korinth.tuta.io@xxxxxxxxxx> wrote:
>
> From: Jens Korinth <jens.korinth@xxxxxxx>
>
> Similar to `Once` in Rust's standard library, but with the same
> non-blocking behavior as the kernel's `DO_ONCE_LITE` macro. Abstraction
> allows easy replacement of the underlying sync mechanisms, see
>
> https://lore.kernel.org/rust-for-linux/20241109-pr_once_macros-v3-0-6beb24e0cac8@xxxxxxx/.
>
> Suggested-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: Jens Korinth <jens.korinth@xxxxxxx>

> + pub fn is_completed(&self) -> bool {
> + self.1.load(Relaxed)
> + }

What is the use-case for this function? Why not just have one atomic?