pub struct ProcessHandle<T> { /* private fields */ }Expand description
Handle to a spawned process. Resolves to the process’s return value.
Dropping the handle before awaiting detaches the process — it continues to run; its return value, if any, is dropped when the process completes.
use simu::SimEnv;
let mut env = SimEnv::with_seed(0);
let h = env.handle();
env.spawn(async move {
let hc = h.clone();
let child = h.spawn(async move {
hc.timeout(3.0).await;
"charged" // the child's return value
});
let result = child.await; // suspend until the child finishes
assert_eq!(result, "charged");
assert_eq!(h.now(), 3.0);
});
env.run();Implementations§
Trait Implementations§
Source§impl<T> Debug for ProcessHandle<T>
impl<T> Debug for ProcessHandle<T>
Source§impl<T: 'static> Future for ProcessHandle<T>
impl<T: 'static> Future for ProcessHandle<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ProcessHandle<T>
impl<T> !Send for ProcessHandle<T>
impl<T> !Sync for ProcessHandle<T>
impl<T> !UnwindSafe for ProcessHandle<T>
impl<T> Freeze for ProcessHandle<T>
impl<T> Unpin for ProcessHandle<T>
impl<T> UnsafeUnpin for ProcessHandle<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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more