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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".