pub struct ResourceRegistry { /* private fields */ }Expand description
no_std + alloc primitive: a per-core LIFO stack of cleanup hooks,
addressed by explicit CoreId rather than ambient thread identity.
Bare-metal or prime-style callers that already know their own core id
use this directly; register_per_core_resource/drain_current_core
are the std-only, TLS-routed convenience for callers with no core id
at hand.
Implementations§
Source§impl ResourceRegistry
impl ResourceRegistry
pub fn new(count: usize) -> Self
Sourcepub fn register(
&self,
core_id: CoreId,
name: impl Into<String>,
on_drop: DropHook,
)
pub fn register( &self, core_id: CoreId, name: impl Into<String>, on_drop: DropHook, )
Register a cleanup hook for core_id. Fires on the matching
Self::drain. Multiple registrations under the same name are
allowed and all fire.
Sourcepub fn drain(&self, core_id: CoreId) -> usize
pub fn drain(&self, core_id: CoreId) -> usize
Drain every hook registered for core_id, LIFO. Returns the number
of hooks executed.
pub fn count(&self) -> usize
Auto Trait Implementations§
impl !RefUnwindSafe for ResourceRegistry
impl !Send for ResourceRegistry
impl !Sync for ResourceRegistry
impl !UnwindSafe for ResourceRegistry
impl Freeze for ResourceRegistry
impl Unpin for ResourceRegistry
impl UnsafeUnpin for ResourceRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more