Skip to main content

SampleCursor

Struct SampleCursor 

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

See this module’s doc comment. Every method takes &self, so one instance can be shared (by reference inside a thread::scope, or behind an Arc) across every lane’s own thread.

Implementations§

Source§

impl SampleCursor

Source

pub const fn new(start: u32, end: u32) -> Self

Builds a cursor over [start, end). For an export, start is wherever a prior sequential phase (remote/hybrid calibration) left samples_done and end is the export’s total samples_per_pixel; for a live epoch it is [0, target_samples); for a coordinator job it is the request’s [first_sample, first_sample + samples).

Source

pub const fn end(&self) -> u32

One past the last sample of this budget.

Source

pub fn claim(&self, want: u32) -> Option<(u32, u32)>

Claims up to want fresh samples for ANY engine, returning Some((start, count)) with 1 <= count <= want, or None if the budget is already exhausted. Never returns a range past end, however large want is.

want == 0 always returns None rather than a zero-length range.

§Why fetch_add alone is enough

One atomic read-modify-write, unconditionally advancing next by want and then checking whether the range it was handed starts past end. fetch_add is inherently exclusive, so every call receives a DISTINCT start with no CAS retry loop needed. next can end up advanced PAST end (the last claim before exhaustion typically requests more than remains) – harmless, since the returned count is clamped to end - start and every later claim sees start >= end and reports None. saturating is not needed in practice (budgets are far below u32::MAX), but fetch_add wraps, so a budget near u32::MAX must not be used.

Source

pub fn claim_local(&self, want: u32) -> Option<(u32, u32)>

Claims for the LOCAL lane only: a previously remote-failed range first (WHOLE, however long it is), falling back to claim once that retry pile is empty. See this module’s doc comment for why a retried range never goes back to remote. The export’s local lane batches whatever it gets; the live viewport uses claim_local_bounded instead.

Source

pub fn claim_local_bounded(&self, want: u32) -> Option<(u32, u32)>

Like claim_local, but never hands out more than want samples even from the retry pile: a longer retried range is split, its head returned now and its tail pushed back to the FRONT of the pile for the next call. The live viewport traces one short frame per claim, so a whole failed remote chunk (possibly hundreds of samples) must not land in a single frame. want == 0 returns None without touching anything.

Source

pub fn claim_any(&self, want: u32) -> Option<(u32, u32)>

Claims for a crate::LanePool lane: up to want samples of a requeued range first (split like claim_local_bounded), falling back to fresh work from claim. Never touches the local-only retry pile. want == 0 returns None without touching anything.

Source

pub fn shared_pool_exhausted(&self) -> bool

Whether the SHARED pool has nothing left to claim – true once every sample up to end has been handed out to some engine. Says nothing about the retry piles. A cheap, lock-free read for callers deciding whether waiting around could still yield work.

Source

pub fn fully_claimed(&self) -> bool

Whether nothing at all is claimable right now: the shared pool is exhausted and both retry piles are empty. A range currently being traced may still come back through requeue or return_to_local if its lane fails.

Source

pub fn return_to_local(&self, start: u32, count: u32)

Returns [start, start + count) to the queue for GUARANTEED local processing after a remote chunk failed to finish it – never re-offered to remote. A count of 0 is a no-op (nothing to retry) rather than an empty queue entry.

Source

pub fn requeue(&self, start: u32, count: u32)

Returns [start, start + count) to the pile every claim_any caller drains first, after a pool lane failed to finish it. A count of 0 is a no-op.

Trait Implementations§

Source§

impl Debug for SampleCursor

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more