#[cfg(not(all(loom, feature = "loom-model")))]
use std::sync::atomic::AtomicBool;
#[cfg(not(all(loom, feature = "loom-model")))]
use std::sync::atomic::Ordering;
#[cfg(all(loom, feature = "loom-model"))]
use loom::sync::atomic::AtomicBool;
#[cfg(all(loom, feature = "loom-model"))]
use loom::sync::atomic::Ordering;
pub(crate) struct NotificationLatch {
notified: AtomicBool,
}
impl NotificationLatch {
#[must_use]
#[inline(always)]
pub(crate) fn new() -> Self {
Self {
notified: AtomicBool::new(false),
}
}
#[inline(always)]
pub(crate) fn clear_notification(&self) {
self.notified.store(false, Ordering::Release);
}
#[inline(always)]
pub(crate) fn notify(&self) {
self.notified.fetch_or(true, Ordering::Release);
}
#[must_use]
#[inline(always)]
pub(crate) fn take_notification(&self) -> bool {
self.notified.swap(false, Ordering::AcqRel)
}
}