Builder

Struct Builder 

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

Configures and builds a Timer

A Builder is obtained by calling wheel().

Implementations§

Source§

impl Builder

Source

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

Set the timer tick duration.

See the crate docs for more detail.

Defaults to 100ms.

Source

pub fn num_slots(self, num_slots: usize) -> Self

Set the number of slots in the timer wheel.

The number of slots must be a power of two.

See the crate docs for more detail.

Defaults to 4,096.

Source

pub fn initial_capacity(self, initial_capacity: usize) -> Self

Set the initial capacity of the timer

The timer’s timeout storage vector will be initialized to this capacity. When the capacity is reached, the storage will be doubled until max_capacity is reached.

Default: 128

Source

pub fn max_capacity(self, max_capacity: usize) -> Self

Set the max capacity of the timer

The timer’s timeout storage vector cannot get larger than this capacity setting.

Default: 4,194,304

Source

pub fn max_timeout(self, max_timeout: Duration) -> Self

Set the max timeout duration that can be requested

Setting the max timeout allows preventing the case of timeout collision in the hash wheel and helps guarantee optimial runtime characteristics.

See the crate docs for more detail.

Defaults to num_slots * tick_duration

Source

pub fn channel_capacity(self, channel_capacity: usize) -> Self

Set the timer communication channel capacity

The timer channel is used to dispatch timeout requests to the timer thread. In theory, the timer thread is able to drain the channel at a very fast rate, however it is always possible for the channel to fill up.

This setting indicates the max number of timeout requests that are able to be buffered before timeout requests are rejected.

Defaults to 128

Source

pub fn thread_name<S: Into<String>>(self, name: S) -> Self

Set the name for the spawned thread.

See also the runtime details in crate docs.

Defaults to “tokio-timer”.

Source

pub fn build(self) -> Timer

Build the configured Timer and return a handle to it.

Trait Implementations§

Source§

impl Debug for Builder

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