Skip to main content

PriorityStreamQueue

Struct PriorityStreamQueue 

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

Lock-light 4-lane priority work-stealing streaming queue with request coalescing, dynamic reprioritization, and atomic cancellation.

Implementations§

Source§

impl PriorityStreamQueue

Coalescing, reprioritization, work-stealing pop, and atomic cancellation routines for PriorityStreamQueue.

Source

pub fn new() -> Self

Creates a new empty 4-lane PriorityStreamQueue.

§Returns
  • Self - Ready priority streaming queue.
Source

pub fn enqueue_or_coalesce( &self, item: StreamWorkItem, telemetry: &StreamingTelemetryCounters, ) -> (StreamRequestHandle, bool)

Enqueues or coalesces an asset streaming job using StreamWorkItem parameters, escalating lane priority and tier when a higher-urgency requester arrives.

§Arguments
  • StreamWorkItem - Initial job specification (generation is assigned by the queue).
  • &StreamingTelemetryCounters - Lock-free telemetry counters updated atomically.
§Returns
  • (StreamRequestHandle, bool) - Request handle paired with true when newly enqueued or false when coalesced.
Source

pub fn reprioritize(&self, key_hash: u64, new_priority: StreamPriority) -> bool

Dynamically reprioritizes an active queued job onto new_priority in O(1) using generation superseding.

§Arguments
  • u64 - Deterministic 64-bit asset key hash.
  • StreamPriority - Updated priority lane.
§Returns
  • bool - true when an active non-cancelled job existed and was reprioritized.
Source

pub fn cancel( &self, key_hash: u64, telemetry: &StreamingTelemetryCounters, ) -> bool

Atomically cancels an active in-flight request, removing it from coalescing and signaling its CancelToken.

§Arguments
  • u64 - Deterministic 64-bit asset key hash to cancel.
  • &StreamingTelemetryCounters - Lock-free telemetry counters.
§Returns
  • bool - true when an active request was found and cancelled.
Source

pub fn is_active_generation(&self, key_hash: u64, generation: u64) -> bool

Returns true when (key_hash, generation) is still the active non-cancelled request.

§Arguments
  • u64 - Asset key hash.
  • u64 - Generation stamped when the work item was popped.
§Returns
  • bool - Whether this job remains valid and uncancelled.
Source

pub fn mark_completed( &self, key_hash: u64, generation: u64, telemetry: &StreamingTelemetryCounters, ) -> bool

Completes (key_hash, generation), removing it from the coalescing registry and decrementing active_jobs exactly once.

§Arguments
  • u64 - Asset key hash.
  • u64 - Generation stamped on the finished work item.
  • &StreamingTelemetryCounters - Lock-free telemetry counters.
§Returns
  • bool - true when the job was still active and completed cleanly, false if already cancelled or superseded.
Source

pub fn pop_highest_priority(&self) -> Option<StreamWorkItem>

Pops the highest-priority valid work item across all 4 lanes with a lock-free fast-path when empty.

§Returns
  • Option<StreamWorkItem> - Highest-priority live work item or None when empty.
Source

pub fn pop_or_steal(&self, worker_index: usize) -> Option<StreamWorkItem>

Pops or steals the next highest-priority valid work item for worker_index.

§Arguments
  • usize - Worker thread index (0 pops FIFO, helper workers steal from lower-lane tails for cache locality).
§Returns
  • Option<StreamWorkItem> - Live work item ready for decoding or None when empty.
Source

pub fn wait_pop_or_steal(&self, worker_index: usize) -> Option<StreamWorkItem>

Parks a native background worker thread on wake_signal until work arrives or shutdown is requested.

§Arguments
  • usize - Worker thread index for work-stealing strategy.
§Returns
  • Option<StreamWorkItem> - Live work item or None once shutdown is signaled and queues are drained.
Source

pub fn request_shutdown(&self)

Signals all parked background worker threads to exit cleanly.

Source

pub fn is_shutdown(&self) -> bool

Returns true when shutdown has been signaled on this queue.

§Returns
  • bool - Whether queue shutdown was requested.
Source

pub fn lane_len(&self, priority: StreamPriority) -> usize

Returns the number of currently queued entries in priority lane.

§Arguments
  • StreamPriority - Priority lane to inspect.
§Returns
  • usize - Current lane queue depth.
Source

pub fn active_count(&self) -> usize

Returns the exact number of active coalesced in-flight requests.

§Returns
  • usize - Count of live in-flight request entries.
Source

pub fn is_empty(&self) -> bool

Returns true when all 4 priority lanes are currently empty.

§Returns
  • bool - Whether all lanes are empty.

Trait Implementations§

Source§

impl Debug for PriorityStreamQueue

Source§

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

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

impl Default for PriorityStreamQueue

Default empty 4-lane priority work-stealing queue.

Source§

fn default() -> Self

Creates an empty PriorityStreamQueue.

§Returns
  • Self - Initialized empty 4-lane queue.

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