Struct Builder

Source
#[non_exhaustive]
pub struct Builder { pub schedule_resolution: Duration, pub gc_threshold: usize, pub channel_capacity: Option<usize>, pub yields_per_spin: usize, /* private fields */ }
Expand description

A builder for Handle.

Returned result of Builder::build or Builder::build_d_ary is a tuple of Handle and its dedicated driver function. The driver function recommended to be spawned as a separate thread.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§schedule_resolution: Duration

Default scheduling resolution for this driver. Setting this to a lower value may decrease CPU usage of the driver, but may also dangerously increase the chance of missing a wakeup event due to the OS scheduler.

§gc_threshold: usize

Aborted nodes that are too far from execution may remain in the driver’s memory for a long time. This value specifies the maximum number of aborted nodes that can be stored in the driver’s memory. If this value is exceeded, the driver will collect garbage.

§channel_capacity: Option<usize>

Set channel capacity. This value is used to initialize the channel that connects the driver and its handles. If the channel is full, the driver will block until the channel is available.

When None is specified, an unbounded channel will be used.

§yields_per_spin: usize

Determines the number of yields per try_recv. This option assumes that the try_recv function contains a relatively heavy routine that is called at spin time, so adjust to an appropriate value to optimize performance.

Value will be clamped to at least 1. Does not use NonZeroUsize, just only for convenience.

Implementations§

Source§

impl Builder

Source

pub fn with_schedule_resolution(self, value: Duration) -> Self

Sets the schedule_resolution field of this struct.

Source

pub fn with_gc_threshold(self, value: usize) -> Self

Sets the gc_threshold field of this struct.

Source

pub fn with_channel_capacity(self, value: impl Into<Option<usize>>) -> Self

Sets the channel_capacity field of this struct.

Source

pub fn with_yields_per_spin(self, value: usize) -> Self

Sets the yields_per_spin field of this struct.

Source§

impl Builder

Source

pub fn build(self) -> (Handle, impl FnOnce())

Build timer driver with optimal configuration.

Source

pub fn build_d_ary<const D: usize>(self) -> (Handle, impl FnOnce())

Build timer driver with desired D-ary heap configuration.

Trait Implementations§

Source§

impl Debug for Builder

Source§

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

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

impl Default for Builder

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.