pub struct SynchronizedVirtualBlock<'callbacks> { /* private fields */ }Expand description
One virtual block with serialized operation access from any host thread.
Default-constructed blocks allocate metadata with the system allocator and
are safe to share immediately. Callback-backed blocks are adopted through
unsafe constructors under the same any-thread contract as VirtualBlock’s
unsafe callback construction. Access serializes per block; independent
blocks run concurrently. There is no GPU or native completion tracking.
Caller-provided diagnostic writers must not reenter this block.
Implementations§
Source§impl<'callbacks> SynchronizedVirtualBlock<'callbacks>
impl<'callbacks> SynchronizedVirtualBlock<'callbacks>
Sourcepub fn new(size: u64) -> Result<Self, AllocError>
pub fn new(size: u64) -> Result<Self, AllocError>
Create TLSF host-only placement behind one mutex. No callbacks are borrowed.
§Errors
Rejects a zero size or failed host metadata reservation.
Sourcepub fn new_with_algorithm(
size: u64,
algorithm: AllocationAlgorithm,
) -> Result<Self, AllocError>
pub fn new_with_algorithm( size: u64, algorithm: AllocationAlgorithm, ) -> Result<Self, AllocError>
Create TLSF or linear host-only placement behind one mutex.
§Errors
Rejects a zero size or failed host metadata reservation.
Sourcepub unsafe fn new_with_callbacks(
size: u64,
algorithm: AllocationAlgorithm,
callbacks: &'callbacks AllocationCallbacks,
) -> Result<Self, AllocError>
pub unsafe fn new_with_callbacks( size: u64, algorithm: AllocationAlgorithm, callbacks: &'callbacks AllocationCallbacks, ) -> Result<Self, AllocError>
Create callback-backed placement behind one mutex.
§Errors
Same errors as VirtualBlock::new_with_callbacks.
§Safety
The complete VirtualBlock::new_with_callbacks contract applies. Callback
code and user data additionally must support calls on any participating
worker thread, not only the constructing thread, through final cleanup.
Sourcepub unsafe fn new_from_block(block: VirtualBlock<'callbacks>) -> Self
pub unsafe fn new_from_block(block: VirtualBlock<'callbacks>) -> Self
Adopt an existing block for serialized access from any host thread.
§Safety
If the block borrows allocation callbacks, their records/code/user data
must satisfy VirtualBlock::new_with_callbacks’s contract and support
calls on any participating worker thread through final cleanup.
Sourcepub fn allocate(
&self,
size: u64,
alignment: u64,
strategy: PlacementStrategy,
) -> Result<VirtualAllocation, AllocError>
pub fn allocate( &self, size: u64, alignment: u64, strategy: PlacementStrategy, ) -> Result<VirtualAllocation, AllocError>
Run VirtualBlock::allocate under this block’s lock.
§Errors
Same errors as VirtualBlock::allocate, plus SynchronizationPoisoned.
Sourcepub fn allocate_upper(
&self,
size: u64,
alignment: u64,
) -> Result<VirtualAllocation, AllocError>
pub fn allocate_upper( &self, size: u64, alignment: u64, ) -> Result<VirtualAllocation, AllocError>
Run VirtualBlock::allocate_upper under this block’s lock.
§Errors
Same errors as VirtualBlock::allocate_upper, plus SynchronizationPoisoned.
Sourcepub fn free(&self, allocation: &mut VirtualAllocation) -> Result<(), AllocError>
pub fn free(&self, allocation: &mut VirtualAllocation) -> Result<(), AllocError>
Run VirtualBlock::free under this block’s lock.
§Errors
Same errors as VirtualBlock::free, plus SynchronizationPoisoned.
Sourcepub fn allocation_info(
&self,
allocation: &VirtualAllocation,
) -> Result<VirtualAllocationInfo, AllocError>
pub fn allocation_info( &self, allocation: &VirtualAllocation, ) -> Result<VirtualAllocationInfo, AllocError>
Run VirtualBlock::allocation_info under this block’s lock.
§Errors
Same errors as VirtualBlock::allocation_info, plus SynchronizationPoisoned.
Sourcepub fn set_user_data(
&self,
allocation: &VirtualAllocation,
data: usize,
) -> Result<(), AllocError>
pub fn set_user_data( &self, allocation: &VirtualAllocation, data: usize, ) -> Result<(), AllocError>
Run VirtualBlock::set_user_data under this block’s lock.
§Errors
Same errors as VirtualBlock::set_user_data, plus SynchronizationPoisoned.
Sourcepub fn is_empty(&self) -> Result<bool, AllocError>
pub fn is_empty(&self) -> Result<bool, AllocError>
Run VirtualBlock::is_empty under this block’s lock.
§Errors
Returns SynchronizationPoisoned after a closure panic.
Sourcepub fn clear(&self) -> Result<(), AllocError>
pub fn clear(&self) -> Result<(), AllocError>
Run VirtualBlock::clear under this block’s lock.
Users of previously returned offsets must stop using them before reuse.
§Errors
Returns SynchronizationPoisoned after a closure panic.
Sourcepub fn statistics(&self) -> Result<VirtualBlockStats, AllocError>
pub fn statistics(&self) -> Result<VirtualBlockStats, AllocError>
Run VirtualBlock::statistics under this block’s lock.
§Errors
Returns SynchronizationPoisoned after a closure panic.
Sourcepub fn detailed_statistics(&self) -> Result<VirtualBlockDetails, AllocError>
pub fn detailed_statistics(&self) -> Result<VirtualBlockDetails, AllocError>
Run VirtualBlock::detailed_statistics under this block’s lock.
§Errors
Returns SynchronizationPoisoned after a closure panic.
Sourcepub fn write_statistics_json(
&self,
output: &mut impl Write,
detailed: bool,
) -> Result<(), AllocError>
pub fn write_statistics_json( &self, output: &mut impl Write, detailed: bool, ) -> Result<(), AllocError>
Sourcepub fn into_inner(
self,
) -> Result<VirtualBlock<'callbacks>, PoisonError<VirtualBlock<'callbacks>>>
pub fn into_inner( self, ) -> Result<VirtualBlock<'callbacks>, PoisonError<VirtualBlock<'callbacks>>>
Recover the exclusive block without native cleanup.
§Errors
PoisonError retains the block for explicit inspection/cleanup after a panic.