Files @ ead29a08c0cf
Branch filter:

Location: CSY/reowolf/src/runtime2/store/mod.rs

ead29a08c0cf 722 B application/rls-services+xml Show Annotation Show as Raw Download as Raw
mh
WIP: Adding ctor/dtor tests to MPSC queue
pub mod component;
pub mod unfair_se_lock;
pub mod queue_mpsc;

pub(crate) use component::ComponentStore;

#[cfg(test)]
mod tests {
    use std::sync::Arc;
    use std::sync::atomic::{AtomicU64, Ordering};

    // Utility resource structure that counts the number of constructors and
    // destructor calls.
    pub struct Resource {
        dtor: Arc<AtomicU64>,
        val: u64,
    }

    impl Resource {
        fn new(ctor: Arc<AtomicU64>, dtor: Arc<AtomicU64>, val: u64) -> Self {
            ctor.fetch_add(1, Ordering::SeqCst);
            return Self{ dtor, val };
        }
    }

    impl Drop for Resource {
        fn drop(&mut self) {
            self.dtor.fetch_add(1, Ordering::SeqCst);
        }
    }
}