Skip to main content

RoutePrewarmer

Struct RoutePrewarmer 

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

Bounded, cancellable, context-validated route pre-warming pipeline.

Implementations§

Source§

impl RoutePrewarmer

Bounded queueing, budgeted slicing, context invalidation, and cancellation for RoutePrewarmer.

Source

pub fn with_limits( max_pending_tasks: usize, max_memory_bytes: usize, max_upload_bytes_per_frame: usize, ) -> Self

Creates a RoutePrewarmer with explicit queue, memory, and per-frame upload byte caps.

§Arguments
  • usize - Maximum pending tasks (>= 1).
  • usize - Maximum aggregate artifact memory in bytes (>= 4096).
  • usize - Maximum bytes uploaded/processed per budgeted frame step (>= 4096).
§Returns
  • Self - Configured route pre-warmer.
Source

pub fn preempt(&mut self)

Preempts speculative route pre-warming immediately when user input or navigation begins.

§Arguments
  • &Self - Mutable route pre-warmer.
Source

pub fn step_idle_post_frame1( &mut self, active_context: PrewarmContextKey, frame_work_us: u64, had_input_or_nav: bool, ) -> usize

Executes real time-sliced post-Frame-1 idle pre-warming strictly within <= 500 us and yields immediately on input or navigation.

§Arguments
  • &Self - Mutable route pre-warmer.
  • PrewarmContextKey - Currently active (version, theme, DPR, locale) context.
  • u64 - Foreground frame CPU duration already spent in microseconds.
  • bool - True when user input, scrolling, or navigation occurred on this frame.
§Returns
  • usize - Number of pre-warm tasks completed during this idle slice.
Source

pub fn enqueue(&mut self, task: RoutePrewarmTask) -> bool

Enqueues task if pre-warming is enabled, context matches, queue has capacity, and no duplicate (route, kind) exists.

§Arguments
  • &Self - Mutable route pre-warmer.
  • RoutePrewarmTask - Candidate pre-warm task.
§Returns
  • bool - true if accepted into the bounded queue.
Source

pub fn invalidate_context(&mut self, next_context: PrewarmContextKey) -> usize

Invalidates all pending tasks and ready artifacts when (resource_version, theme_mode, dpr) changes.

§Arguments
  • &Self - Mutable route pre-warmer.
  • PrewarmContextKey - Newly active (version, theme, DPR) context key.
§Returns
  • usize - Total stale pending tasks plus invalidated ready artifacts discarded.
Source

pub fn cancel_route(&mut self, route_key: &str) -> usize

Cancels all pending tasks and discards ready artifacts targeting route_key.

§Arguments
  • &Self - Mutable route pre-warmer.
  • &str - Route key to cancel.
§Returns
  • usize - Total cancelled pending tasks and discarded artifacts for route_key.
Source

pub fn cancel_all(&mut self) -> usize

Immediately cancels every pending pre-warm task and drops all ready speculative artifacts (e.g. under memory pressure).

§Arguments
  • &Self - Mutable route pre-warmer.
§Returns
  • usize - Total cancelled tasks and evicted artifacts.
Source

pub fn step_budgeted( &mut self, active_context: PrewarmContextKey, budget_us: u64, ) -> usize

Executes queued pre-warm tasks strictly within budget_us, per-frame upload caps, and memory limits.

§Arguments
  • &Self - Mutable route pre-warmer.
  • PrewarmContextKey - Currently active (version, theme, DPR) context.
  • u64 - Remaining microsecond budget available on this frame (0 uses default_step_budget_us).
§Returns
  • usize - Number of tasks completed during this frame slice.
Source

pub fn take_ready_artifact( &mut self, route_key: &str, active_context: PrewarmContextKey, ) -> Option<PrewarmedRouteArtifact>

Consumes and returns a ready pre-warmed artifact for route_key ONLY when its (version, theme, DPR) context matches active_context.

§Arguments
  • &Self - Mutable route pre-warmer.
  • &str - Route key being entered.
  • PrewarmContextKey - Currently active (version, theme, DPR) context.
§Returns
  • Option<PrewarmedRouteArtifact> - Valid artifact if matched, or None if absent or stale.
Source§

impl RoutePrewarmer

Source

pub fn get_max_pending_tasks(&self) -> usize

Source

pub fn get_mut_max_pending_tasks(&mut self) -> &mut usize

Source

pub fn set_max_pending_tasks(&mut self, val: usize) -> &mut Self

Source

pub fn get_max_memory_bytes(&self) -> usize

Source

pub fn get_mut_max_memory_bytes(&mut self) -> &mut usize

Source

pub fn set_max_memory_bytes(&mut self, val: usize) -> &mut Self

Source

pub fn get_max_upload_bytes_per_frame(&self) -> usize

Source

pub fn get_mut_max_upload_bytes_per_frame(&mut self) -> &mut usize

Source

pub fn set_max_upload_bytes_per_frame(&mut self, val: usize) -> &mut Self

Source

pub fn get_default_step_budget_us(&self) -> u64

Source

pub fn get_mut_default_step_budget_us(&mut self) -> &mut u64

Source

pub fn set_default_step_budget_us(&mut self, val: u64) -> &mut Self

Source

pub fn get_active_context(&self) -> PrewarmContextKey

Source

pub fn get_mut_active_context(&mut self) -> &mut PrewarmContextKey

Source

pub fn set_active_context(&mut self, val: PrewarmContextKey) -> &mut Self

Source

pub fn get_enabled(&self) -> bool

Source

pub fn get_mut_enabled(&mut self) -> &mut bool

Source

pub fn set_enabled(&mut self, val: bool) -> &mut Self

Source

pub fn get_pending(&self) -> &Vec<RoutePrewarmTask>

Source

pub fn get_mut_pending(&mut self) -> &mut Vec<RoutePrewarmTask>

Source

pub fn set_pending(&mut self, val: Vec<RoutePrewarmTask>) -> &mut Self

Source

pub fn get_ready(&self) -> &Vec<PrewarmedRouteArtifact>

Source

pub fn get_mut_ready(&mut self) -> &mut Vec<PrewarmedRouteArtifact>

Source

pub fn set_ready(&mut self, val: Vec<PrewarmedRouteArtifact>) -> &mut Self

Source

pub fn get_resident_bytes(&self) -> usize

Source

pub fn get_enqueued_count(&self) -> u64

Source

pub fn get_executed_tasks(&self) -> u64

Source

pub fn get_cancelled_tasks(&self) -> u64

Source

pub fn get_invalidated_artifacts(&self) -> u64

Source

pub fn get_budget_deferrals(&self) -> u64

Source

pub fn get_preempted_until_idle(&self) -> bool

Source

pub fn get_idle_slices_executed(&self) -> u64

Trait Implementations§

Source§

impl Clone for RoutePrewarmer

Source§

fn clone(&self) -> Self

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 RoutePrewarmer

Source§

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

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

impl Default for RoutePrewarmer

Default bounded RoutePrewarmer initialized with conservative memory and per-frame slice caps.

Source§

fn default() -> Self

Creates a default RoutePrewarmer with 32 max tasks, 8 MiB memory cap, and 1 MiB/frame upload cap.

§Returns
  • Self - Ready route pre-warmer.

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