jay-compositor 1.15.0

The Jay compositor
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering::Relaxed;

pub struct Condition {
    enabled: AtomicU64,
}

pub struct EnabledCondition {
    condition: &'static Condition,
}

impl Condition {
    #[allow(dead_code)]
    fn enable(&'static self) -> EnabledCondition {
        self.enabled.fetch_add(1, Relaxed);
        EnabledCondition { condition: self }
    }

    #[allow(dead_code)]
    fn enabled(&self) -> bool {
        self.enabled.load(Relaxed) > 0
    }
}

impl Drop for EnabledCondition {
    fn drop(&mut self) {
        self.condition.enabled.fetch_sub(1, Relaxed);
    }
}

macro_rules! ad_hoc_conditions {
    ($($ident:ident,)*) => {
        $(
            pub static $ident: Condition = Condition {
                enabled: AtomicU64::new(0),
            };
        )*
    };
}

ad_hoc_conditions! {}