Skip to main content

TimeoutQueueBuilder

Struct TimeoutQueueBuilder 

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

Builder for a TimeoutQueue, mirroring WheelBuilder.

The timeout duration is fixed up front in new — that is the whole point of the type, so it cannot be a per-schedule parameter later.

§Examples

use std::time::{Duration, Instant};
use nexus_timer::{TimeoutQueue, TimeoutQueueBuilder};

let now = Instant::now();

// 5-second timeout, unbounded storage, default 1ms tick.
let list: TimeoutQueue<u64> = TimeoutQueueBuilder::new(Duration::from_secs(5))
    .unbounded(4096)
    .build(now)
    .unwrap();

// Custom tick, bounded storage.
let list: nexus_timer::BoundedTimeoutQueue<u64> =
    TimeoutQueueBuilder::new(Duration::from_millis(250))
        .tick_duration(Duration::from_micros(100))
        .bounded(1024)
        .build(now)
        .unwrap();

Implementations§

Source§

impl TimeoutQueueBuilder

Source

pub fn new(timeout: Duration) -> Self

Creates a builder with the fixed timeout every timer will use.

Tick duration defaults to 1ms. The timeout must be non-zero — this is not checked here but enforced at build, which returns ConfigError otherwise.

Source

pub fn tick_duration(self, d: Duration) -> Self

Sets the tick duration (internal time quantum). Default: 1ms.

Source

pub fn unbounded(self, chunk_capacity: usize) -> UnboundedTimeoutQueueBuilder

Transitions to an unbounded (growable) builder.

chunk_capacity is the slab chunk size (entries per chunk); the slab grows by adding chunks as needed.

Source

pub fn bounded(self, capacity: usize) -> BoundedTimeoutQueueBuilder

Transitions to a bounded (fixed-capacity) builder.

capacity is the maximum number of concurrent timers.

Trait Implementations§

Source§

impl Clone for TimeoutQueueBuilder

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 Copy for TimeoutQueueBuilder

Source§

impl Debug for TimeoutQueueBuilder

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