Skip to main content

PreparedAllocationRelease

Struct PreparedAllocationRelease 

Source
pub struct PreparedAllocationRelease { /* private fields */ }
Expand description

Final ownership of one allocation, detached from its live record.

A prepared request is produced only after the binding identity and the allocation generation matched and the live record was removed exactly once under the per-mechanism lock. From that moment the allocation is AllocationReleaseState::Queued: no view, commit, or second release can match it, and address reuse cannot resurrect it.

The request pins the allocator, the accounting authority, and the provider context, so a queue may hold it across mechanism retirement and across threads.

§Abandonment is safe

Dropping a prepared request without calling execute quarantines it: the ownership is recorded at the mechanism with residual facts, and no allocator call and no blocking wait happen in Drop.

Implementations§

Source§

impl PreparedAllocationRelease

Source

pub const fn identity(&self) -> AllocationIdentity

Source

pub const fn binding_identity(&self) -> BindingIdentity

Source

pub const fn device(&self) -> DeviceKey

Source

pub const fn authority(&self) -> AuthorityIdentity

The pinned accounting authority. A manager refunds against this identity even if the mechanism has since been retired.

Source

pub const fn provider_context(&self) -> ProviderContextIdentity

The pinned provider context. The queue that owns this request belongs to this context.

Source

pub fn allocator(&self) -> &Arc<dyn DeviceAllocator>

The pinned allocator that must perform the physical release.

Source

pub const fn as_ptr(&self) -> NonNull<u8>

The address to release. Never dereferenced by this crate.

Source

pub const fn len(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn alignment(&self) -> usize

Source

pub const fn state(&self) -> AllocationReleaseState

Always AllocationReleaseState::Queued: the live record is gone and the bytes are not released yet.

Source

pub fn execute(self) -> AllocationReleaseOutcome

Perform the physical release through the pinned allocator.

Returns AllocationReleaseOutcome::Complete or AllocationReleaseOutcome::Quarantined, never AllocationReleaseOutcome::Failed: the live record was already retired at preparation, so “nothing changed” is no longer representable here and an allocator-level Failed is conservatively quarantined.

§Lock order

The mechanism lifecycle is read under the mechanism lock, that lock is dropped, the allocator runs with no lock held, and the final state is then recorded under the mechanism lock again. The registry lock is never taken here, so the two lock classes are still never nested.

Device loss observed at this point never reaches the allocator: the request finishes as device-lost quarantine and keeps its pins.

Source

pub fn quarantine_device_lost(self) -> AllocationReleaseOutcome

Settle this request as device-lost quarantine, without calling the allocator and without refunding anything.

This is the same settlement execute performs when it observes a device-lost release gate, exposed for the case where the provider’s queue learns the context is unusable first: the mechanism lifecycle may not have been invalidated yet, so execute would still be allowed to call the allocator, which is exactly what must not happen.

It is deliberately distinct from quarantine(QuarantineReason::DeviceLost), which records the generic AllocationReleaseState::Quarantined. Device loss is its own terminal state because it is discharged by confirmed context/process termination rather than by anything the runtime can do to the device.

Consuming the request is the point: the binding records the exact allocation identity as device-lost, the queued-release count settles, and the active-operation pin — with the mechanism, provider-context, and binding references behind it — is released, so a queue that holds the residual does not keep its own provider context alive.

Source

pub fn quarantine(self, reason: QuarantineReason) -> AllocationReleaseOutcome

Retain ownership deliberately without calling the allocator.

This is the explicit form of what Drop does implicitly.

Trait Implementations§

Source§

impl Debug for PreparedAllocationRelease

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for PreparedAllocationRelease

Source§

fn drop(&mut self)

Quarantine an abandoned request.

This never calls the allocator, never enqueues, and never waits. It takes only the per-mechanism lock, which is a leaf in the documented lock order, and records residual ownership so the bytes stay accounted for.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for PreparedAllocationRelease

Source§

impl Sync for PreparedAllocationRelease

Auto Trait Implementations§

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> BindingResource for T
where T: Send + Sync + Debug,

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.