pub struct DelayExecutor { /* private fields */ }Expand description
Executor that starts each task after a fixed delay.
DelayExecutor is a small non-blocking submission strategy for cases where
one task should run later while the caller must return immediately. It
models delayed start, not minimum execution duration.
Each accepted task gets its own helper OS thread. The helper thread sleeps for the configured delay and then runs the task. This keeps the submitting thread unblocked without requiring a shared timer, queue, runtime, or scheduler worker. It is intentionally not a general-purpose delayed task scheduler and does not coalesce timers across tasks.
The returned TrackedTask is created immediately. Dropping the handle does
not cancel the helper thread; use TrackedTask::cancel before the helper
thread starts the task when pre-start cancellation is needed.
Implementations§
Trait Implementations§
Source§impl Clone for DelayExecutor
impl Clone for DelayExecutor
Source§fn clone(&self) -> DelayExecutor
fn clone(&self) -> DelayExecutor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Executor for DelayExecutor
impl Executor for DelayExecutor
Source§fn call<C, R, E>(&self, task: C) -> Result<TrackedTask<R, E>, SubmissionError>
fn call<C, R, E>(&self, task: C) -> Result<TrackedTask<R, E>, SubmissionError>
Starts a helper thread that waits and then runs the callable.
This method returns after the helper thread has been spawned; it does not wait for the configured delay or for task completion.
§Parameters
task- Callable to run after the configured delay.
§Returns
A TrackedTask for the delayed task.
§Errors
Returns SubmissionError::WorkerSpawnFailed if the helper thread
cannot be created.