pub trait JoinHandleExt<T> {
// Required method
fn join_timeout(
self,
timeout: Duration,
) -> Result<T, Box<dyn Any + Send + 'static>>;
}Expand description
Extension trait for JoinHandle to add timeout functionality
Required Methods§
Sourcefn join_timeout(
self,
timeout: Duration,
) -> Result<T, Box<dyn Any + Send + 'static>>
fn join_timeout( self, timeout: Duration, ) -> Result<T, Box<dyn Any + Send + 'static>>
Join with a timeout, returning an error if the timeout is exceeded
This implementation properly handles timeout by using a dedicated timeout thread that will exit immediately, avoiding resource leaks. The original thread continues running in the background if it doesn’t finish within the timeout.