pub fn with_timeout<T>(timeout: std::time::Duration, action: T) -> bool
where
    T: FnOnce() + std::marker::Send + 'static,
{
    let (tx, rx) = std::sync::mpsc::channel();
    std::thread::spawn(move || {
        action();
        tx.send(()).unwrap();
    });
    rx.recv_timeout(timeout).is_ok()
}
/// Execute the provided closure on a separate thread, but with a timeout.
/// Return true if the action completed successfully and false otherwise.
Execute the provided closure on a separate thread, but with a timeout.
Return true if the action completed successfully and false otherwise.
Execute the provided closure on a separate thread but with a timeout . Return true if the action completed successfully and false otherwise .
pub fn with_timeout<T>(timeout: std::time::Duration, action: T) -> bool
where
    T: FnOnce() + std::marker::Send + 'static,
{
    let (tx, rx) = std::sync::mpsc::channel();
    std::thread::spawn(move || {
        action();
        tx.send(()).unwrap();
    });
    rx.recv_timeout(timeout).is_ok()
}
pub fn with_timeout < T > ( timeout : std :: time :: Duration , action : T ) -> bool where T : FnOnce ( ) + std :: marker :: Send + ' static , { let ( tx , rx ) = std :: sync :: mpsc :: channel ( ) ; std :: thread :: spawn ( move | | { action ( ) ; tx . send ( ( ) ) . unwrap ( ) ; } ) ; rx . recv_timeout ( timeout ) . is_ok ( ) }
Execute the provided closure on a separate thread, but with a timeout.
Execute the provided closure on a separate thread but with a timeout .
timeout
std::time::Duration
action
T
timeout
std::time::Duration
action
T