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
impl TimeoutQueueBuilder
Sourcepub fn new(timeout: Duration) -> Self
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.
Sourcepub fn tick_duration(self, d: Duration) -> Self
pub fn tick_duration(self, d: Duration) -> Self
Sets the tick duration (internal time quantum). Default: 1ms.
Sourcepub fn unbounded(self, chunk_capacity: usize) -> UnboundedTimeoutQueueBuilder
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.
Sourcepub fn bounded(self, capacity: usize) -> BoundedTimeoutQueueBuilder
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
impl Clone for TimeoutQueueBuilder
impl Copy for TimeoutQueueBuilder
Auto Trait Implementations§
impl Freeze for TimeoutQueueBuilder
impl RefUnwindSafe for TimeoutQueueBuilder
impl Send for TimeoutQueueBuilder
impl Sync for TimeoutQueueBuilder
impl Unpin for TimeoutQueueBuilder
impl UnsafeUnpin for TimeoutQueueBuilder
impl UnwindSafe for TimeoutQueueBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more