pub struct ProductionControl<'a> { /* private fields */ }Expand description
Allocation and cancellation inputs borrowed for one production call. An ordinary call has no allowance or cancellation scope; a controlled call preserves both the original retained owner and the invoking reader.
Implementations§
Source§impl<'a> ProductionControl<'a>
impl<'a> ProductionControl<'a>
pub const fn uncontrolled() -> Self
pub fn new( budget: &'a MemoryBudget, original: &'a CancellationToken, invoking: &'a CancellationToken, ) -> Self
pub fn budget(&self) -> Option<&'a MemoryBudget>
pub fn check_cancellation(&self) -> Result<(), QueryCancelled>
pub fn check(&self) -> Result<(), ValueRetentionError>
pub fn empty_reservation(&self) -> Option<MemoryReservation>
Sourcepub fn reserve(
&self,
bytes: usize,
) -> Result<Option<MemoryReservation>, ValueRetentionError>
pub fn reserve( &self, bytes: usize, ) -> Result<Option<MemoryReservation>, ValueRetentionError>
Admit an explicitly known allocation layout before its constructor runs.
Sourcepub fn combine(
&self,
left: Option<MemoryReservation>,
right: Option<MemoryReservation>,
) -> Option<MemoryReservation>
pub fn combine( &self, left: Option<MemoryReservation>, right: Option<MemoryReservation>, ) -> Option<MemoryReservation>
Transfer two leases for allocations already owned by the same composite result. This does not produce, copy or replace a value.
Sourcepub fn finish<T>(
&self,
value: T,
memory: Option<MemoryReservation>,
) -> Result<Produced<T>, ValueRetentionError>
pub fn finish<T>( &self, value: T, memory: Option<MemoryReservation>, ) -> Result<Produced<T>, ValueRetentionError>
Associate a value with leases acquired by its constructors. Every owned allocation must already belong to the supplied reservation. The explicit pair prevents a representation-changing closure from silently introducing new payloads; callers must construct and admit those payloads at their owner.
Sourcepub fn retain_external_value(
&self,
value: Value,
) -> Result<Produced<Value>, ValueRetentionError>
pub fn retain_external_value( &self, value: Value, ) -> Result<Produced<Value>, ValueRetentionError>
Accept a completed value from an external producer whose construction is outside this resource scope. This admission boundary retains its exposed owned capacities without copying; built-in constructors must instead reserve before allocating. The value precedes its accumulating lease on every error path.