Skip to main content

SynchronizedVirtualBlock

Struct SynchronizedVirtualBlock 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> Result<bool, AllocError>

Run VirtualBlock::is_empty under this block’s lock.

§Errors

Returns SynchronizationPoisoned after a closure panic.

Source

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.

Source

pub fn statistics(&self) -> Result<VirtualBlockStats, AllocError>

Run VirtualBlock::statistics under this block’s lock.

§Errors

Returns SynchronizationPoisoned after a closure panic.

Source

pub fn detailed_statistics(&self) -> Result<VirtualBlockDetails, AllocError>

Run VirtualBlock::detailed_statistics under this block’s lock.

§Errors

Returns SynchronizationPoisoned after a closure panic.

Source

pub fn write_statistics_json( &self, output: &mut impl Write, detailed: bool, ) -> Result<(), AllocError>

Run VirtualBlock::write_statistics_json under this block’s lock.

§Errors

Same errors as VirtualBlock::write_statistics_json, plus SynchronizationPoisoned.

§Panics

A writer panic propagates and poisons subsequent operations. Writers must not reenter the block while this method holds its lock.

Source

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.

Auto Trait Implementations§

§

impl<'callbacks> !Freeze for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> Forget for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> Move for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> RefUnwindSafe for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> Send for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> Sync for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> Unpin for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> UnsafeUnpin for SynchronizedVirtualBlock<'callbacks>

§

impl<'callbacks> UnwindSafe for SynchronizedVirtualBlock<'callbacks>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.