Skip to main content

SpinOptions

Struct SpinOptions 

Source
pub struct SpinOptions {
    pub timeout: Option<Duration>,
    pub only_next: bool,
    pub max_callbacks: Option<usize>,
    pub poll_interval: Duration,
    pub stop_on_first_error: bool,
}
Expand description

Options controlling a blocking spin loop — rclrs’s SpinOptions.

Consumed by Executor::spin (runs until one of these conditions ends it) and by Executor::spin_forever (which can only honour poll_interval and stop_on_first_error — it never returns).

This type is where the RTOS divergence lives. phase-427 moved Executor::spin onto rclrs’s name and shape so a ported rclrs file needs no rename on that line; the two things ours must say and rclrs’s has no field for — how long one iteration may wait on the transport, and whether a failed callback ends the loop — are fields HERE rather than extra verbs. The three fields rclrs does have (timeout, only_next, max_callbacks) keep their upstream meaning.

Fields§

§timeout: Option<Duration>

Stop after this duration.

phase-379 W5 — a Duration, not a u64 of milliseconds. The _ms suffix was inconsistent with the two methods that consume these options (Executor::spin_once and Executor::spin already take core::time::Duration) as well as with rclrs’s SpinOptions::timeout. Milliseconds ARE the unit the platform ABI’s wait primitives take, but that conversion belongs at the ABI boundary, where it already happens — not in the public option a user writes.

§only_next: bool

Only process immediately available work (single iteration)

§max_callbacks: Option<usize>

Stop after processing this many callbacks total

§poll_interval: Duration

OURS-ONLY — how long one iteration may wait on the transport.

Each pass of the loop is spin_once(poll_interval), so this is the granularity at which every OTHER exit condition here is observed: a cancel() from another task, a timeout expiring, max_callbacks being reached. rclrs has no counterpart because its executor waits on a wait-set with no such quantum; ours is a poll loop by RFC-0002, and the quantum is a real number a caller has to be able to set.

Defaults to DEFAULT_SPIN_POLL_INTERVAL (10 ms).

§stop_on_first_error: bool

OURS-ONLY — end the loop at the first pass in which a callback failed.

rclrs collects every callback error into the Vec<RclrsError> its spin returns and the caller picks with .first_error(). There is no allocator here, so ours returns Result<(), NodeError> carrying the FIRST error — and a channel that can hold one error has to say when it stops looking. false (the default) keeps today’s behaviour: a failed callback is counted in SpinOnceResult and the loop continues.

Implementations§

Source§

impl SpinOptions

Source

pub const fn new() -> SpinOptions

Create default spin options (spin forever until halted)

Source

pub const fn timeout(self, timeout: Duration) -> SpinOptions

Set a timeout duration.

Matches rclrs’s SpinOptions::timeout(Duration). Stays const — ours is a strict superset there, and Duration::from_millis is const-stable well below this workspace’s MSRV, so SpinOptions::new().timeout( Duration::from_millis(50)) is usable in a const context.

Source

pub const fn spin_once() -> SpinOptions

Only process one round of work (equivalent to spin_once)

Source

pub const fn max_callbacks(self, n: usize) -> SpinOptions

Stop after processing N callbacks

Source

pub const fn poll_interval(self, poll_interval: Duration) -> SpinOptions

Set the per-iteration transport budget. See poll_interval.

Source

pub const fn stop_on_first_error(self, stop: bool) -> SpinOptions

End the loop at the first failed callback. See stop_on_first_error.

Trait Implementations§

Source§

impl Clone for SpinOptions

Source§

fn clone(&self) -> SpinOptions

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 SpinOptions

Source§

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

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

impl Default for SpinOptions

Source§

fn default() -> SpinOptions

Not derived: Duration::default() is ZERO, which would turn every SpinOptions::default() spin into a busy-poll.

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.