pub struct Sinks { /* private fields */ }Expand description
Callbacks used by CountingAlloc.
Fields are private so safe code cannot construct a sink that violates the global
allocator contract. Use Self::noop or the unsafe Self::new constructor.
Implementations§
Source§impl Sinks
impl Sinks
Sourcepub const unsafe fn new(alloc: fn(u64), realloc: fn(u64), dealloc: fn()) -> Self
pub const unsafe fn new(alloc: fn(u64), realloc: fn(u64), dealloc: fn()) -> Self
Construct a certified sink set.
§Safety
Every callback must remain valid for the program’s lifetime and must never unwind, allocate, deallocate, acquire a lock, or otherwise re-enter the global allocator. It must also remain callable during thread-local destruction. All arithmetic in a callback must be non-panicking in every build profile.
fn allocation(_size: u64) {}
fn reallocation(_growth: u64) {}
fn deallocation() {}
// SAFETY: these empty callbacks cannot unwind, allocate, lock, or re-enter.
let sinks = unsafe {
fdu_core::counters::alloc::Sinks::new(allocation, reallocation, deallocation)
};
let _allocator =
fdu_core::counters::alloc::CountingAlloc::system(sinks);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sinks
impl RefUnwindSafe for Sinks
impl Send for Sinks
impl Sync for Sinks
impl Unpin for Sinks
impl UnsafeUnpin for Sinks
impl UnwindSafe for Sinks
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