pub struct RuntimeTaskContext { /* private fields */ }Implementations§
Source§impl RuntimeTaskContext
impl RuntimeTaskContext
pub fn new( cancellation: RuntimeCancellationToken, deadline: Option<Instant>, ) -> RuntimeTaskContext
pub fn without_deadline( cancellation: RuntimeCancellationToken, ) -> RuntimeTaskContext
pub fn with_timeout(timeout: Duration) -> RuntimeTaskContext
pub fn cancellation(&self) -> &RuntimeCancellationToken
pub fn child(&self) -> RuntimeTaskContext
Sourcepub fn constrained_by(
&self,
request: &RuntimeTaskContext,
) -> Result<RuntimeTaskContext, HawDBError>
pub fn constrained_by( &self, request: &RuntimeTaskContext, ) -> Result<RuntimeTaskContext, HawDBError>
Applies statement constraints without replacing an enclosing admission. Cancellation from either scope stops the statement; cancelling the combined scope does not cancel its parents. Budgets remain shared and can only tighten. Independent controllers cannot represent one admission and are rejected.
Sourcepub fn with_admission_priority(
self,
priority: RuntimeWorkPriority,
) -> RuntimeTaskContext
pub fn with_admission_priority( self, priority: RuntimeWorkPriority, ) -> RuntimeTaskContext
Selects the resource pool (and queue rank) of runtime admissions made for this task.
Synchronous embedded entry points (EmbeddedStoreHandle reads,
queries and typed maintenance) admit at the lower of this priority and
the priority the operation would otherwise use: a context can move
foreground work into the Background pool, never promote background
maintenance. Defaults to Foreground. The Background pool has its own
task limit and I/O depth (one task on hosts with fewer than eight
CPUs) and yields under critical memory pressure.
The Background pool is shared with automatic checkpoints and other
maintenance. Work that holds it – in particular a long read – delays
the checkpoint that committing writers may be waiting for, so prefer
Self::with_admission_queue_priority, which only lowers the queue
rank. The context never moves a transaction into the Background pool: for a mutation
this setting lowers only its queue rank, because its commit can depend
on Background maintenance.
pub fn admission_priority(&self) -> RuntimeWorkPriority
Sourcepub fn with_admission_queue_priority(
self,
priority: RuntimeWorkPriority,
) -> RuntimeTaskContext
pub fn with_admission_queue_priority( self, priority: RuntimeWorkPriority, ) -> RuntimeTaskContext
Lowers only where this task’s admissions rank in the governor’s queue, keeping them in the resource pool of the operation (#1947).
A Background-ranked waiter is ordered behind Foreground-ranked
waiters (FIFO among equals, with one-time aging), and immediate
Foreground requests may take free capacity ahead of it. Because it
stays out of the Background pool, it can never hold the slot an
automatic checkpoint needs. Defaults to Foreground; the effective
rank is also lowered by Self::with_admission_priority.
pub fn admission_queue_priority(&self) -> RuntimeWorkPriority
Sourcepub fn with_admission_wait(self, timeout: Duration) -> RuntimeTaskContext
pub fn with_admission_wait(self, timeout: Duration) -> RuntimeTaskContext
Waits up to timeout in the runtime governor’s priority-ordered
admission queue instead of refusing at once when capacity is short.
The wait window starts now. Ordering, highest first:
- immediate (non-waiting) Foreground-ranked requests take free
capacity ahead of queued Background-ranked waiters until those have
queued for 100 ms, or always on a governor with strict Foreground
precedence (
RuntimeGovernor::set_foreground_preempts_queued_background); - queued waiters by rank (see
Self::with_admission_queue_priority), Foreground before Background and FIFO within a rank, except that a Background-ranked waiter queued for 100 ms is selected ahead of Foreground-ranked waiters, at most once per Foreground waiter; - other immediate requests yield to the selected waiter with a
retryable
queued_aheadrefusal when they compete with it for a resource it is short of (or would make it short of).
When the window ends, the admission returns the typed
RuntimeAdmissionRefused with the last shortage and waited set to
the time queued; cancellation or the task deadline while queued returns
RuntimeTaskStopped. A timeout that overflows the clock waits without
an admission deadline. No store lock is held while queued. Attach a
RuntimeAdmissionTrace to observe how long granted admissions queued.
Never wait for an admission while holding another permit the queue head needs, such as inside a transaction or read-snapshot callback: the outer permit stays held, so on a one-CPU governor an unbounded nested wait without a task deadline never returns.
Sourcepub fn with_admission_wait_policy(
self,
wait: RuntimeAdmissionWait,
) -> RuntimeTaskContext
pub fn with_admission_wait_policy( self, wait: RuntimeAdmissionWait, ) -> RuntimeTaskContext
Like Self::with_admission_wait with an explicit policy, including
RuntimeAdmissionWait::Refuse to restore the default.
pub fn admission_wait(&self) -> RuntimeAdmissionWait
Sourcepub fn with_admission_trace(
self,
trace: RuntimeAdmissionTrace,
) -> RuntimeTaskContext
pub fn with_admission_trace( self, trace: RuntimeAdmissionTrace, ) -> RuntimeTaskContext
Records each runtime admission made for this task, and how long it
queued, in a caller-held trace (see RuntimeAdmissionTrace).
pub fn admission_trace(&self) -> Option<&RuntimeAdmissionTrace>
Sourcepub fn record_admission(&self, queued_for: Duration)
pub fn record_admission(&self, queued_for: Duration)
Called by admission adapters when they grant this task an admission.
Sourcepub fn with_admitted_parallelism(
self,
admitted_parallelism: NonZero<usize>,
) -> RuntimeTaskContext
pub fn with_admitted_parallelism( self, admitted_parallelism: NonZero<usize>, ) -> RuntimeTaskContext
Carries the CPU parallelism already reserved by the runtime governor.
This is an execution ceiling, not a request to create worker threads. Executors must still apply their operator memory and input-size limits.
pub fn admitted_parallelism(&self) -> NonZero<usize>
Sourcepub fn with_executor_thread_limit(
self,
limit: NonZero<usize>,
) -> RuntimeTaskContext
pub fn with_executor_thread_limit( self, limit: NonZero<usize>, ) -> RuntimeTaskContext
Carries the physical executor-thread ceiling derived by the runtime governor.
This is distinct from Self::admitted_parallelism, which is the CPU
reservation for one task. An absent limit denotes an ungoverned library call.
pub fn executor_thread_limit(&self) -> Option<NonZero<usize>>
Sourcepub fn with_memory_reservation(
self,
reservation: RuntimeMemoryReservation,
) -> RuntimeTaskContext
pub fn with_memory_reservation( self, reservation: RuntimeMemoryReservation, ) -> RuntimeTaskContext
Carries the memory already reserved by the runtime governor.
Governed executors must use this reservation instead of a static per-query configuration limit. An absent reservation denotes an ungoverned library call and preserves the configured fallback.
pub fn memory_reservation(&self) -> Option<RuntimeMemoryReservation>
Sourcepub fn has_resource_controllers(&self) -> bool
pub fn has_resource_controllers(&self) -> bool
Whether execution carries dynamic resource controllers rather than only a static ceiling. Synchronous adapters must preserve these controllers and must not replace an originating governor admission with a local cap.
Sourcepub fn with_memory_target(
self,
target: Arc<dyn RuntimeMemoryTarget>,
) -> RuntimeTaskContext
pub fn with_memory_target( self, target: Arc<dyn RuntimeMemoryTarget>, ) -> RuntimeTaskContext
Carries host-driven pressure feedback to revocable operator work areas.
Sourcepub fn working_memory_target(&self, hard_limit: u64) -> u64
pub fn working_memory_target(&self, hard_limit: u64) -> u64
The target can only tighten the caller’s ceiling. Operators retain a bounded progress floor and continue to enforce all hard allocation limits.
Sourcepub fn with_memory_controller(
self,
controller: Arc<dyn RuntimeMemoryController>,
) -> RuntimeTaskContext
pub fn with_memory_controller( self, controller: Arc<dyn RuntimeMemoryController>, ) -> RuntimeTaskContext
Binds actual allocation ownership to an already admitted task.
Sourcepub fn reserve_working_memory(
&self,
bytes: u64,
) -> Result<Option<Box<dyn RuntimeMemoryPermit>>, RuntimeMemoryError>
pub fn reserve_working_memory( &self, bytes: u64, ) -> Result<Option<Box<dyn RuntimeMemoryPermit>>, RuntimeMemoryError>
Reserve before allocating and retain the returned lease until destruction.
Clones and children share their controller. Ungoverned contexts return
None; a supplied static ceiling still limits an individual allocation.
Sourcepub fn with_io_wave_controller(
self,
controller: Arc<dyn RuntimeIoWaveController>,
) -> RuntimeTaskContext
pub fn with_io_wave_controller( self, controller: Arc<dyn RuntimeIoWaveController>, ) -> RuntimeTaskContext
Binds the controller owned by a successful runtime admission.
Sourcepub fn acquire_io_wave(
&self,
slots: NonZero<usize>,
) -> Result<Option<Box<dyn RuntimeIoWavePermit>>, RuntimeIoWaveError>
pub fn acquire_io_wave( &self, slots: NonZero<usize>, ) -> Result<Option<Box<dyn RuntimeIoWavePermit>>, RuntimeIoWaveError>
Acquires capacity for one storage I/O wave when this is an admitted context.
Raw contexts have no controller and return Ok(None). The returned
permit must remain live only while physical reads are in flight.
Sourcepub fn try_acquire_io_wave(
&self,
slots: NonZero<usize>,
) -> Result<RuntimeIoWaveTryAcquire, RuntimeIoWaveError>
pub fn try_acquire_io_wave( &self, slots: NonZero<usize>, ) -> Result<RuntimeIoWaveTryAcquire, RuntimeIoWaveError>
Attempts to acquire capacity for one storage I/O wave without blocking.
Raw, ungoverned contexts return Acquired(None). Governed contexts
return Pending while another wave owns the requested capacity.
Sourcepub fn with_work_limit(self, limit: usize) -> RuntimeTaskContext
pub fn with_work_limit(self, limit: usize) -> RuntimeTaskContext
Starts a bounded execution scope while retaining every parent limit and the original cancellation, memory and I/O admission. Clones share usage.
pub fn has_work_limit(&self) -> bool
pub fn work_units(&self) -> usize
Sourcepub fn remaining_work(&self) -> Option<usize>
pub fn remaining_work(&self) -> Option<usize>
Work still chargeable under every enclosing limit, or None without one.
Sourcepub fn check_work_limit(&self) -> Result<(), HawDBError>
pub fn check_work_limit(&self) -> Result<(), HawDBError>
Preserve a typed refusal across adapters whose error transport is text.
Sourcepub fn charge_work(&self, units: usize) -> Result<(), HawDBError>
pub fn charge_work(&self, units: usize) -> Result<(), HawDBError>
Charge explicit candidate work before examining it, including rejected candidates. Checkpoints and allocation byte counts are not work units.
pub fn deadline(&self) -> Option<Instant>
pub fn remaining(&self) -> Option<Duration>
pub fn checkpoint(&self) -> Result<(), RuntimeCancellationReason>
Sourcepub fn check_cancellation(&self) -> Result<(), RuntimeCancellationReason>
pub fn check_cancellation(&self) -> Result<(), RuntimeCancellationReason>
Observe cancellation without reading the clock. Batched callers pair
this per-step check with Self::check_deadline_at at bounded
boundaries that already own a timestamp.
Sourcepub fn check_deadline_at(
&self,
now: Instant,
) -> Result<(), RuntimeCancellationReason>
pub fn check_deadline_at( &self, now: Instant, ) -> Result<(), RuntimeCancellationReason>
Compare the deadline with a caller-supplied timestamp.
Trait Implementations§
Source§impl Clone for RuntimeTaskContext
impl Clone for RuntimeTaskContext
Source§fn clone(&self) -> RuntimeTaskContext
fn clone(&self) -> RuntimeTaskContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RuntimeTaskContext
impl Debug for RuntimeTaskContext
Source§impl Default for RuntimeTaskContext
impl Default for RuntimeTaskContext
Source§fn default() -> RuntimeTaskContext
fn default() -> RuntimeTaskContext
Auto Trait Implementations§
impl !RefUnwindSafe for RuntimeTaskContext
impl !UnwindSafe for RuntimeTaskContext
impl Forget for RuntimeTaskContext
impl Freeze for RuntimeTaskContext
impl Move for RuntimeTaskContext
impl Send for RuntimeTaskContext
impl Sync for RuntimeTaskContext
impl Unpin for RuntimeTaskContext
impl UnsafeUnpin for RuntimeTaskContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more