pub struct SaaTrackingAllocator<A = System> { /* private fields */ }Expand description
A wrapper around a GlobalAlloc implementation (like std::alloc::System)
that intercepts allocation calls to update the global memory counters defined
in khora_core::memory.
This allocator is the key to enabling the SAA’s memory monitoring. By registering
it as the #[global_allocator], all heap allocations made by the application
will be tracked, providing essential telemetry to the Dynamic Context Core (DCC).
§Type Parameters
A: The underlying allocator that will perform the actual memory allocation. Defaults toSystem, the standard Rust allocator.
§Usage
use khora_data::allocators::SaaTrackingAllocator;
#[global_allocator]
static GLOBAL: SaaTrackingAllocator = SaaTrackingAllocator::new(std::alloc::System);Implementations§
Source§impl<A> SaaTrackingAllocator<A>
impl<A> SaaTrackingAllocator<A>
Sourcepub const fn new(inner: A) -> SaaTrackingAllocator<A>
pub const fn new(inner: A) -> SaaTrackingAllocator<A>
Creates a new tracking allocator that wraps the given inner allocator.
Trait Implementations§
Source§impl<A> Clone for SaaTrackingAllocator<A>where
A: Clone,
impl<A> Clone for SaaTrackingAllocator<A>where
A: Clone,
Source§fn clone(&self) -> SaaTrackingAllocator<A>
fn clone(&self) -> SaaTrackingAllocator<A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<A> Debug for SaaTrackingAllocator<A>where
A: Debug,
impl<A> Debug for SaaTrackingAllocator<A>where
A: Debug,
Source§impl<A> Default for SaaTrackingAllocator<A>where
A: Default,
impl<A> Default for SaaTrackingAllocator<A>where
A: Default,
Source§fn default() -> SaaTrackingAllocator<A>
fn default() -> SaaTrackingAllocator<A>
Source§impl<A> GlobalAlloc for SaaTrackingAllocator<A>where
A: GlobalAlloc,
impl<A> GlobalAlloc for SaaTrackingAllocator<A>where
A: GlobalAlloc,
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory and updates tracking counters.
§Safety
This function is unsafe because it is part of the GlobalAlloc trait.
The caller must ensure that layout has a non-zero size.
Source§unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
Deallocates memory and updates tracking counters.
§Safety
This function is unsafe because it is part of the GlobalAlloc trait.
The caller must ensure that ptr was allocated by this allocator with the same layout.
impl<A> Copy for SaaTrackingAllocator<A>where
A: Copy,
Auto Trait Implementations§
impl<A> Freeze for SaaTrackingAllocator<A>where
A: Freeze,
impl<A> RefUnwindSafe for SaaTrackingAllocator<A>where
A: RefUnwindSafe,
impl<A> Send for SaaTrackingAllocator<A>where
A: Send,
impl<A> Sync for SaaTrackingAllocator<A>where
A: Sync,
impl<A> Unpin for SaaTrackingAllocator<A>where
A: Unpin,
impl<A> UnwindSafe for SaaTrackingAllocator<A>where
A: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().