Struct ExecutorConfig

Source
pub struct ExecutorConfig {
    pub total_threads_range: AtomicRangeStrict<AtomicUsize>,
    pub temporary_threads_range: AtomicRangeStrict<AtomicUsize>,
    /* private fields */
}
Expand description

Configuration of Executor.

Fields§

§total_threads_range: AtomicRangeStrict<AtomicUsize>

minimum..=maximum number of total executor threads.

§temporary_threads_range: AtomicRangeStrict<AtomicUsize>

maximum number of temporary executors. if setting to 0, it will disable preempt (spawn new temporary executor if too busy).

it is not recommended to disable this, due to Asyncute is designed for “hang-up-free”.

for example, if user runs blocking I/O or CPU-bound tasks in one of executor (or even many executors), then some new temporary executors will be spawn “as soon as busy”.

this is primacy different in “blocking handle” between Asyncute and Goroutine.

in Golang, if a goroutine is used for blocking, all of asynchronous IO poll tasks will be moved to a native OS thread other than the thread of blocking goroutine used to executes blocking operations. this is not essential, and make the design more complexity.

in Asyncute, if a Future is used for blocking, this is no problem! all other idle executors will continues to handle async tasks, and no move needed (due to asyncute does not have per-executor queues for working-stealing).

Implementations§

Source§

impl ExecutorConfig

Source

pub const MIN_INTERVAL: Duration

the minimum interval of executor loop.

Source

pub const MAX_INTERVAL: Duration

the maximum interval of executor loop.

Source

pub const fn global() -> &'static Self

get the global instance of ExecutorConfig.

Source

pub fn interval(&self) -> Duration

get the executor interval.

Source

pub fn set_interval(&self, val: Duration) -> bool

set the executor interval.

Source

pub fn spawn_policy(&self) -> ExecutorSpawnPolicy

get the executor spawn policy.

Source

pub fn set_spawn_policy(&self, policy: ExecutorSpawnPolicy)

set the executor spawn policy.

Source

pub fn overload_threshold(&self) -> f64

get the threshold of overload.

Source

pub fn set_overload_threshold(&self, val: f64) -> bool

set the threshold of overload.

Source

pub fn standby_threshold(&self) -> f64

get the threshold of standby.

Source

pub fn set_standby_threshold(&self, val: f64) -> bool

set the threshold of standby.

Trait Implementations§

Source§

impl Debug for ExecutorConfig

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.