Struct web_thread::web::ScopeJoinFuture
source · pub struct ScopeJoinFuture<'scope, 'env, T>(/* private fields */);
Available on
Web
only.Expand description
Waits for the associated scope to finish. See ScopeFuture::into_wait()
.
§Notes
Keep in mind that if dropped it will block, or spinloop if blocking is not
supported on this thread (see has_block_support()
), until all threads
are joined.
Implementations§
source§impl<T> ScopeJoinFuture<'_, '_, T>
impl<T> ScopeJoinFuture<'_, '_, T>
sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true
if all threads have finished.
§Notes
When this returns true
it guarantees ScopeJoinFuture::join_all()
not to block.
sourcepub fn join_all(self) -> T
pub fn join_all(self) -> T
This will block until all associated threads are finished.
§Panics
- If the calling thread doesn’t support blocking, see
web::has_block_support()
. Though it is guaranteed to not block ifScopeJoinFuture::is_finished()
returnstrue
. Alternatively consider just polling thisFuture
to completion. - If called after being polled to completion.
§Example
let value = AtomicUsize::new(0);
let future = web_thread::web::scope_async(|scope| async {
(0..3).for_each(|_| {
scope.spawn(|| value.fetch_add(1, Ordering::Relaxed));
});
value.fetch_add(1, Ordering::Relaxed);
}).into_wait().await;
// This will block until all threads are done.
future.join_all();
assert_eq!(value.load(Ordering::Relaxed), 4);
Trait Implementations§
source§impl<T> Debug for ScopeJoinFuture<'_, '_, T>
impl<T> Debug for ScopeJoinFuture<'_, '_, T>
source§impl<T> Future for ScopeJoinFuture<'_, '_, T>
impl<T> Future for ScopeJoinFuture<'_, '_, T>
Auto Trait Implementations§
impl<'scope, 'env, T> Freeze for ScopeJoinFuture<'scope, 'env, T>where
T: Freeze,
impl<'scope, 'env, T> RefUnwindSafe for ScopeJoinFuture<'scope, 'env, T>where
T: RefUnwindSafe,
impl<'scope, 'env, T> Send for ScopeJoinFuture<'scope, 'env, T>where
T: Send,
impl<'scope, 'env, T> Sync for ScopeJoinFuture<'scope, 'env, T>where
T: Sync,
impl<'scope, 'env, T> Unpin for ScopeJoinFuture<'scope, 'env, T>
impl<'scope, 'env, T> !UnwindSafe for ScopeJoinFuture<'scope, 'env, 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<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§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