pub struct ThreadLocalStrategy { /* private fields */ }
Expand description
Thread-local memory tracking strategy Optimized for multi-threaded applications with minimal cross-thread coordination Each thread maintains its own allocation records to avoid lock contention
Implementations§
Source§impl ThreadLocalStrategy
impl ThreadLocalStrategy
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new thread-local strategy instance Initializes global coordination structures
Sourcepub fn register_current_thread(&self) -> Result<(), TrackerError>
pub fn register_current_thread(&self) -> Result<(), TrackerError>
Register current thread for tracking Must be called from each thread that will participate in tracking
Sourcepub fn track_allocation(
&self,
ptr: usize,
size: usize,
var_name: Option<String>,
type_name: String,
) -> Result<(), TrackerError>
pub fn track_allocation( &self, ptr: usize, size: usize, var_name: Option<String>, type_name: String, ) -> Result<(), TrackerError>
Track memory allocation in current thread Records allocation with thread-local storage for maximum performance
Sourcepub fn track_deallocation(&self, ptr: usize) -> Result<(), TrackerError>
pub fn track_deallocation(&self, ptr: usize) -> Result<(), TrackerError>
Track memory deallocation in current thread Updates existing allocation record with deallocation timestamp
Trait Implementations§
Source§impl Default for ThreadLocalStrategy
impl Default for ThreadLocalStrategy
Source§impl MemoryTracker for ThreadLocalStrategy
impl MemoryTracker for ThreadLocalStrategy
Source§fn initialize(&mut self, config: TrackerConfig) -> Result<(), TrackerError>
fn initialize(&mut self, config: TrackerConfig) -> Result<(), TrackerError>
Initialize strategy with provided configuration Sets up global coordination structures
Source§fn start_tracking(&mut self) -> Result<(), TrackerError>
fn start_tracking(&mut self) -> Result<(), TrackerError>
Start active memory tracking across all threads
Source§fn stop_tracking(&mut self) -> Result<Vec<u8>, TrackerError>
fn stop_tracking(&mut self) -> Result<Vec<u8>, TrackerError>
Stop tracking and collect data from all threads
Source§fn get_statistics(&self) -> TrackerStatistics
fn get_statistics(&self) -> TrackerStatistics
Get current tracking statistics aggregated across all threads
Source§fn tracker_type(&self) -> TrackerType
fn tracker_type(&self) -> TrackerType
Get strategy type identifier
Auto Trait Implementations§
impl Freeze for ThreadLocalStrategy
impl RefUnwindSafe for ThreadLocalStrategy
impl Send for ThreadLocalStrategy
impl Sync for ThreadLocalStrategy
impl Unpin for ThreadLocalStrategy
impl UnwindSafe for ThreadLocalStrategy
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> 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