Skip to main content

task_with_timeout

Function task_with_timeout 

Source
pub fn task_with_timeout<M, F>(timeout: Duration, f: F, on_timeout: M) -> Cmd<M>
where M: Send + 'static, F: FnOnce(CancellationToken) -> M + Send + 'static,
Expand description

Create a Cmd::Task that enforces a cooperative timeout.

The worker closure receives a CancellationToken and must honor it for timely timeout teardown. On timeout, the runtime requests cancellation and returns on_timeout; any late worker result is discarded.