Logo

Programming-Idioms

  • Fortran
  • JS
  • Rust
  • D

Idiom #230 Timeout

Cancel an ongoing processing p if it has not finished after 5s.

use tokio::time::{timeout, Duration};
timeout(Duration::from_secs(5), p()).await;
def main(p) do
  p
  |> Task.async()
  |> Task.await()
end

New implementation...
< >
programming-idioms.org