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
impl PreparedAllocationRelease
pub const fn identity(&self) -> AllocationIdentity
pub const fn binding_identity(&self) -> BindingIdentity
pub const fn device(&self) -> DeviceKey
The pinned accounting authority. A manager refunds against this identity even if the mechanism has since been retired.
Sourcepub const fn provider_context(&self) -> ProviderContextIdentity
pub const fn provider_context(&self) -> ProviderContextIdentity
The pinned provider context. The queue that owns this request belongs to this context.
Sourcepub fn allocator(&self) -> &Arc<dyn DeviceAllocator> ⓘ
pub fn allocator(&self) -> &Arc<dyn DeviceAllocator> ⓘ
The pinned allocator that must perform the physical release.
Sourcepub const fn as_ptr(&self) -> NonNull<u8>
pub const fn as_ptr(&self) -> NonNull<u8>
The address to release. Never dereferenced by this crate.
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub const fn alignment(&self) -> usize
Sourcepub const fn state(&self) -> AllocationReleaseState
pub const fn state(&self) -> AllocationReleaseState
Always AllocationReleaseState::Queued: the live record is gone and
the bytes are not released yet.
Sourcepub fn execute(self) -> AllocationReleaseOutcome
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.
Sourcepub fn quarantine_device_lost(self) -> AllocationReleaseOutcome
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.
Sourcepub fn quarantine(self, reason: QuarantineReason) -> AllocationReleaseOutcome
pub fn quarantine(self, reason: QuarantineReason) -> AllocationReleaseOutcome
Retain ownership deliberately without calling the allocator.
This is the explicit form of what Drop does implicitly.