pub struct CoreExecutor { /* private fields */ }
Expand description
A CoreExecutor
is the most simple executor provided. It runs a single thread, which is
responsible for both scheduling the function (registering the timer for the wakeup),
and the actual execution. The executor will stop once dropped. The CoreExecutor
can be cloned to generate a new reference to the same underlying executor.
Given the single threaded nature of this executor, tasks are executed sequentially, and a long
running task will cause delay in other subsequent executions.
Implementations§
Source§impl CoreExecutor
impl CoreExecutor
Sourcepub fn new() -> Result<CoreExecutor, Error>
pub fn new() -> Result<CoreExecutor, Error>
Creates a new CoreExecutor
.
Sourcepub fn with_name(thread_name: &str) -> Result<CoreExecutor, Error>
pub fn with_name(thread_name: &str) -> Result<CoreExecutor, Error>
Creates a new CoreExecutor
with the specified thread name.
Sourcepub fn schedule_fixed_interval<F>(
&self,
initial: Duration,
interval: Duration,
scheduled_fn: F,
) -> TaskHandle
pub fn schedule_fixed_interval<F>( &self, initial: Duration, interval: Duration, scheduled_fn: F, ) -> TaskHandle
Schedule a function for running at fixed intervals. The executor will try to run the
function every interval
, but if one execution takes longer than interval
it will delay
all the subsequent calls.
Sourcepub fn schedule_fixed_rate<F>(
&self,
initial: Duration,
interval: Duration,
scheduled_fn: F,
) -> TaskHandle
pub fn schedule_fixed_rate<F>( &self, initial: Duration, interval: Duration, scheduled_fn: F, ) -> TaskHandle
Schedule a function for running at fixed rate. The executor will try to run the function
every interval
, and if a task execution takes longer than interval
, the wait time
between task will be reduced to decrease the overall delay.