Skip to main content

RuntimeTaskContext

Struct RuntimeTaskContext 

Source
pub struct RuntimeTaskContext { /* private fields */ }

Implementations§

Source§

impl RuntimeTaskContext

Source

pub fn new( cancellation: RuntimeCancellationToken, deadline: Option<Instant>, ) -> RuntimeTaskContext

Source

pub fn without_deadline( cancellation: RuntimeCancellationToken, ) -> RuntimeTaskContext

Source

pub fn with_timeout(timeout: Duration) -> RuntimeTaskContext

Source

pub fn cancellation(&self) -> &RuntimeCancellationToken

Source

pub fn child(&self) -> RuntimeTaskContext

Source

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.

Source

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.

Source

pub fn admission_priority(&self) -> RuntimeWorkPriority

Source

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.

Source

pub fn admission_queue_priority(&self) -> RuntimeWorkPriority

Source

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:

  1. 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);
  2. 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;
  3. other immediate requests yield to the selected waiter with a retryable queued_ahead refusal 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.

Source

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.

Source

pub fn admission_wait(&self) -> RuntimeAdmissionWait

Source

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).

Source

pub fn admission_trace(&self) -> Option<&RuntimeAdmissionTrace>

Source

pub fn record_admission(&self, queued_for: Duration)

Called by admission adapters when they grant this task an admission.

Source

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.

Source

pub fn admitted_parallelism(&self) -> NonZero<usize>

Source

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.

Source

pub fn executor_thread_limit(&self) -> Option<NonZero<usize>>

Source

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.

Source

pub fn memory_reservation(&self) -> Option<RuntimeMemoryReservation>

Source

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.

Source

pub fn with_memory_target( self, target: Arc<dyn RuntimeMemoryTarget>, ) -> RuntimeTaskContext

Carries host-driven pressure feedback to revocable operator work areas.

Source

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.

Source

pub fn with_memory_controller( self, controller: Arc<dyn RuntimeMemoryController>, ) -> RuntimeTaskContext

Binds actual allocation ownership to an already admitted task.

Source

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.

Source

pub fn with_io_wave_controller( self, controller: Arc<dyn RuntimeIoWaveController>, ) -> RuntimeTaskContext

Binds the controller owned by a successful runtime admission.

Source

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.

Source

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.

Source

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.

Source

pub fn has_work_limit(&self) -> bool

Source

pub fn work_units(&self) -> usize

Source

pub fn remaining_work(&self) -> Option<usize>

Work still chargeable under every enclosing limit, or None without one.

Source

pub fn check_work_limit(&self) -> Result<(), HawDBError>

Preserve a typed refusal across adapters whose error transport is text.

Source

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.

Source

pub fn deadline(&self) -> Option<Instant>

Source

pub fn remaining(&self) -> Option<Duration>

Source

pub fn checkpoint(&self) -> Result<(), RuntimeCancellationReason>

Source

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.

Source

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

Source§

fn clone(&self) -> RuntimeTaskContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RuntimeTaskContext

Source§

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

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

impl Default for RuntimeTaskContext

Source§

fn default() -> RuntimeTaskContext

Returns the “default value” for a type. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> RetainedArrowCodeOwner for T
where T: Debug + Send + Sync,

Source§

impl<T> RuntimeIoWavePermit for T
where T: Debug + Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.