diff --git a/src/runtime2/store/mod.rs b/src/runtime2/store/mod.rs index f5ee1f0a39c16b8dfb05cd55cc8a62d5f85e0abd..2280851592f0825f9e3a253f27090f01eb44c38d 100644 --- a/src/runtime2/store/mod.rs +++ b/src/runtime2/store/mod.rs @@ -3,3 +3,29 @@ 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, + val: u64, + } + + impl Resource { + fn new(ctor: Arc, dtor: Arc, 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); + } + } +} \ No newline at end of file