pub struct TaskFuture { /* private fields */ }Expand description
A future that tracks completion of submitted tasks
TaskFuture provides both blocking and non-blocking ways to wait for
task completion. Tasks can be checked for completion, waited on
indefinitely, or waited on with a timeout.
TaskFuture is cheaply cloneable. However, it captures the thread handle
of the thread that created it.
If sharing the future with other threads, is_complete() is safe to call
from anywhere.
Important: wait() and wait_timeout() must be called from the
same thread that created the TaskFuture. Calling these methods from a
different thread will panic in debug builds and may cause the calling thread
to hang indefinitely in release builds.
Implementations§
Source§impl TaskFuture
impl TaskFuture
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all tasks are complete without blocking
Returns true if all tasks have finished execution.
This is a non-blocking operation using atomic loads.
Sourcepub fn wait(&self)
pub fn wait(&self)
Wait for all tasks to complete
First checks completion with an atomic load; if incomplete, parks the thread that sent the work.
Sourcepub fn wait_timeout(&self, timeout: Duration) -> bool
pub fn wait_timeout(&self, timeout: Duration) -> bool
Wait for all tasks to complete with a timeout
First checks completion with an atomic load; if incomplete, parks the thread that sent the work.
Returns true if all tasks completed within the timeout,
false if the timeout was reached first.
Trait Implementations§
Source§impl Clone for TaskFuture
impl Clone for TaskFuture
Source§fn clone(&self) -> TaskFuture
fn clone(&self) -> TaskFuture
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more