pub struct Builder { /* private fields */ }Expand description
Configures and builds a Timer
A Builder is obtained by calling wheel().
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn tick_duration(self, tick_duration: Duration) -> Self
pub fn tick_duration(self, tick_duration: Duration) -> Self
Set the timer tick duration.
See the crate docs for more detail.
Defaults to 100ms.
Sourcepub fn num_slots(self, num_slots: usize) -> Self
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.
Sourcepub fn initial_capacity(self, initial_capacity: usize) -> Self
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
Sourcepub fn max_capacity(self, max_capacity: usize) -> Self
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
Sourcepub fn max_timeout(self, max_timeout: Duration) -> Self
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
Sourcepub fn channel_capacity(self, channel_capacity: usize) -> Self
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
Sourcepub fn thread_name<S: Into<String>>(self, name: S) -> Self
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”.