conc-util 0.1.0

[no_std] utilities for concurrency and async
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use core::sync::atomic::{AtomicBool, Ordering};

pub struct OnceFlag(AtomicBool);

impl OnceFlag {
    pub fn new() -> Self {
        Self(AtomicBool::new(false))
    }

    pub fn fire(&self) -> bool {
        self.0.swap(true, Ordering::AcqRel)
    }

    pub fn fired(&self) -> bool {
        self.0.load(Ordering::Acquire)
    }
}