pub struct AnalyticsContext { /* private fields */ }Expand description
Context for analytics operations with grouped buffer lifecycle.
All buffers allocated through this context are released together when the context is dropped. This is useful for analytics operations that need multiple temporary buffers.
§Thread Safety
AnalyticsContext is Send but not Sync. Each context should be
used from a single thread. For parallel analytics, create a separate
context per thread.
Implementations§
Source§impl AnalyticsContext
impl AnalyticsContext
Sourcepub fn new(name: impl Into<String>) -> AnalyticsContext
pub fn new(name: impl Into<String>) -> AnalyticsContext
Sourcepub fn with_capacity(
name: impl Into<String>,
expected_allocations: usize,
) -> AnalyticsContext
pub fn with_capacity( name: impl Into<String>, expected_allocations: usize, ) -> AnalyticsContext
Create a context with pre-allocated capacity.
Reserves space for the expected number of allocations to avoid reallocations of the internal vectors.
Sourcepub fn allocate(&mut self, size: usize) -> AllocationHandle
pub fn allocate(&mut self, size: usize) -> AllocationHandle
Sourcepub fn allocate_typed<T>(&mut self, count: usize) -> AllocationHandle
pub fn allocate_typed<T>(&mut self, count: usize) -> AllocationHandle
Sourcepub fn get(&self, handle: AllocationHandle) -> &[u8] ⓘ
pub fn get(&self, handle: AllocationHandle) -> &[u8] ⓘ
Sourcepub fn get_mut(&mut self, handle: AllocationHandle) -> &mut [u8] ⓘ
pub fn get_mut(&mut self, handle: AllocationHandle) -> &mut [u8] ⓘ
Sourcepub fn get_typed<T>(&self, handle: AllocationHandle) -> &[T]where
T: Copy,
pub fn get_typed<T>(&self, handle: AllocationHandle) -> &[T]where
T: Copy,
Sourcepub fn get_typed_mut<T>(&mut self, handle: AllocationHandle) -> &mut [T]where
T: Copy,
pub fn get_typed_mut<T>(&mut self, handle: AllocationHandle) -> &mut [T]where
T: Copy,
Sourcepub fn try_get(&self, handle: AllocationHandle) -> Option<&[u8]>
pub fn try_get(&self, handle: AllocationHandle) -> Option<&[u8]>
Try to get a reference to an allocated buffer.
Returns None if the handle is invalid.
Sourcepub fn try_get_mut(&mut self, handle: AllocationHandle) -> Option<&mut [u8]>
pub fn try_get_mut(&mut self, handle: AllocationHandle) -> Option<&mut [u8]>
Try to get a mutable reference to an allocated buffer.
Returns None if the handle is invalid.
Sourcepub fn allocation_size(&self, handle: AllocationHandle) -> usize
pub fn allocation_size(&self, handle: AllocationHandle) -> usize
Sourcepub fn allocation_count(&self) -> usize
pub fn allocation_count(&self) -> usize
Get the number of allocations in this context.
Sourcepub fn stats(&self) -> &ContextStats
pub fn stats(&self) -> &ContextStats
Get statistics for this context.
Sourcepub fn release_all(&mut self)
pub fn release_all(&mut self)
Release all allocations and reset the context.
After calling this, all handles become invalid.
Sourcepub fn sub_context(&self, name: impl Into<String>) -> AnalyticsContext
pub fn sub_context(&self, name: impl Into<String>) -> AnalyticsContext
Create a sub-context for a nested operation.
The sub-context shares no allocations with the parent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnalyticsContext
impl RefUnwindSafe for AnalyticsContext
impl Send for AnalyticsContext
impl Sync for AnalyticsContext
impl Unpin for AnalyticsContext
impl UnwindSafe for AnalyticsContext
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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