pub trait ScheduledExecutorService: ExecutorService {
// Required method
fn schedule_callable_at<C, R, E>(
&self,
instant: Instant,
task: C,
) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
where C: Callable<R, E> + Send + 'static,
R: Send + 'static,
E: Send + 'static;
// Provided methods
fn schedule<T, E>(
&self,
delay: Duration,
task: T,
) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static,
E: Send + 'static { ... }
fn schedule_callable<C, R, E>(
&self,
delay: Duration,
task: C,
) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
where C: Callable<R, E> + Send + 'static,
R: Send + 'static,
E: Send + 'static { ... }
fn schedule_at<T, E>(
&self,
instant: Instant,
task: T,
) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
where T: Runnable<E> + Send + 'static,
E: Send + 'static { ... }
}Expand description
Managed executor service with delayed and instant-based submission support.
ScheduledExecutorService extends ExecutorService with per-task timing.
A normal submit call is an immediate submission; schedule and
schedule_at accept work now but delay the task start until the requested
time. Successful submission only means the service accepted the scheduled
task. Task success, failure, panic, or cancellation is observed through the
returned tracked handle.
Required Methods§
Sourcefn schedule_callable_at<C, R, E>(
&self,
instant: Instant,
task: C,
) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
fn schedule_callable_at<C, R, E>( &self, instant: Instant, task: C, ) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
Schedules a callable task to start at a monotonic instant.
§Parameters
instant- Monotonic instant at which the task becomes runnable.task- Callable to execute at or after the instant.
§Returns
A tracked handle for observing or cancelling the scheduled task.
§Errors
Returns SubmissionError when the service refuses the task before
accepting it.
Provided Methods§
Sourcefn schedule<T, E>(
&self,
delay: Duration,
task: T,
) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
fn schedule<T, E>( &self, delay: Duration, task: T, ) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
Schedules a runnable task to start after the supplied delay.
§Parameters
delay- Minimum delay before the task becomes runnable.task- Runnable to execute after the delay elapses.
§Returns
A tracked handle for observing or cancelling the scheduled task.
§Errors
Returns SubmissionError when the service refuses the task before
accepting it.
Sourcefn schedule_callable<C, R, E>(
&self,
delay: Duration,
task: C,
) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
fn schedule_callable<C, R, E>( &self, delay: Duration, task: C, ) -> Result<Self::TrackedHandle<R, E>, SubmissionError>
Schedules a callable task to start after the supplied delay.
§Parameters
delay- Minimum delay before the task becomes runnable.task- Callable to execute after the delay elapses.
§Returns
A tracked handle for observing or cancelling the scheduled task.
§Errors
Returns SubmissionError when the service refuses the task before
accepting it.
Sourcefn schedule_at<T, E>(
&self,
instant: Instant,
task: T,
) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
fn schedule_at<T, E>( &self, instant: Instant, task: T, ) -> Result<Self::TrackedHandle<(), E>, SubmissionError>
Schedules a runnable task to start at a monotonic instant.
§Parameters
instant- Monotonic instant at which the task becomes runnable.task- Runnable to execute at or after the instant.
§Returns
A tracked handle for observing or cancelling the scheduled task.
§Errors
Returns SubmissionError when the service refuses the task before
accepting it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.