diff --git a/src/runtime2/runtime.rs b/src/runtime2/runtime.rs index 4255058472a74d8a9f8ce05a1720bc0169d71cf7..846a60389f8b022adcb7810efa45f05effcc3a83 100644 --- a/src/runtime2/runtime.rs +++ b/src/runtime2/runtime.rs @@ -16,7 +16,7 @@ use super::store::{ComponentStore, QueueDynMpsc, QueueDynProducer}; /// of these. Only with a key one may retrieve privately-accessible memory for /// a component. Practically just a generational index, like `CompId` is. #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub(crate) struct CompKey(u32); +pub(crate) struct CompKey(pub u32); impl CompKey { pub(crate) fn downgrade(&self) -> CompId { @@ -26,7 +26,7 @@ impl CompKey { /// Generational ID of a component #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct CompId(u32); +pub struct CompId(pub u32); impl CompId { pub(crate) fn new_invalid() -> CompId { @@ -51,6 +51,9 @@ pub(crate) struct RuntimeComp { } /// Should contain everything that is accessible in a thread-safe manner +// TODO: Do something about the `num_handles` thing. This needs to be a bit more +// "foolproof" to lighten the mental burden of using the `num_handles` +// variable. pub(crate) struct CompPublic { pub sleeping: AtomicBool, pub num_handles: AtomicU32, // manually modified (!) @@ -199,6 +202,7 @@ impl Runtime { } pub(crate) fn destroy_component(&self, key: CompKey) { + debug_assert_eq!(self.get_component(key).public.num_handles.load(Ordering::Acquire), 0); self.components.destroy(key.0); }