Struct async_spin_sleep::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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.schedule_resolution: DurationDefault 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: usizeAborted 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: usizeDetermines 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
impl Builder
sourcepub fn with_schedule_resolution(self, value: Duration) -> Self
pub fn with_schedule_resolution(self, value: Duration) -> Self
Sets the schedule_resolution field of this struct.
sourcepub fn with_gc_threshold(self, value: usize) -> Self
pub fn with_gc_threshold(self, value: usize) -> Self
Sets the gc_threshold field of this struct.
sourcepub fn with_channel_capacity(self, value: impl Into<Option<usize>>) -> Self
pub fn with_channel_capacity(self, value: impl Into<Option<usize>>) -> Self
Sets the channel_capacity field of this struct.
sourcepub fn with_yields_per_spin(self, value: usize) -> Self
pub fn with_yields_per_spin(self, value: usize) -> Self
Sets the yields_per_spin field of this struct.