pub struct SyncJoinHandle<T: Send + Sync + 'static> { /* private fields */ }Expand description
Join handle for a task on the compute runtime.
Implementations§
Source§impl<T: Send + Sync + 'static> SyncJoinHandle<T>
impl<T: Send + Sync + 'static> SyncJoinHandle<T>
Sourcepub fn join(self) -> Result<T>
pub fn join(self) -> Result<T>
Blocks the current thread until the other os thread has finished. Use this only in synchronous code. In async code, use tokio’s spawn_blocking.
§Errors
Returns an error if the underlying task panicked.
§Examples
use xet_runtime::core::spawn_os_thread;
let handle = spawn_os_thread(|| 42);
let result = handle.join().unwrap();
assert_eq!(result, 42);Sourcepub fn try_join(&self) -> Result<Option<T>>
pub fn try_join(&self) -> Result<Option<T>>
Attempts to retrieve the result without blocking.
- Returns
Ok(Some(value))if the task is complete. - Returns
Ok(None)if the task is still running. - Returns an
Err(...)variant if
§Examples
use xet_runtime::core::{SyncJoinHandle, spawn_os_thread};
let handle: SyncJoinHandle<_> = spawn_os_thread(|| 42);
// Possibly do some work here...
match handle.try_join() {
Ok(Some(value)) => println!("Value is ready: {}", value),
Ok(None) => println!("Still running"),
Err(e) => eprintln!("Error: {:?}", e),
}Auto Trait Implementations§
impl<T> Freeze for SyncJoinHandle<T>
impl<T> !RefUnwindSafe for SyncJoinHandle<T>
impl<T> Send for SyncJoinHandle<T>
impl<T> !Sync for SyncJoinHandle<T>
impl<T> Unpin for SyncJoinHandle<T>
impl<T> UnsafeUnpin for SyncJoinHandle<T>
impl<T> !UnwindSafe for SyncJoinHandle<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more