pub fn run_with_timeout<F, U>(closure: F, timeout: Duration) -> Result<U>
where F: FnOnce() -> U + Send + 'static, U: Send + 'static,
Expand description

Run the provided closure in a separate thread and return it’s result. If the closure does not finish before the timeout is reached, an Error is returned instead.

WARNING: It is not possible to kill the closure if a timeout occurs. It is advised to panic when an error is returned.