Skip to main content

WaitMember

Struct WaitMember 

Source
pub struct WaitMember<'group> { /* private fields */ }
Expand description

A wait object owned by a CleanupGroup.

Behaves like ThreadpoolWait but is released by the group rather than by its own drop, and the watched handle is owned by the group.

Implementations§

Source§

impl WaitMember<'_>

Source

pub fn handle(&self) -> BorrowedHandle<'_>

Borrow the watched handle, for signalling or inspecting it.

Source

pub fn arm(&self, timeout: Option<Duration>)

Arm the wait, so the next signal or timeout runs the callback once.

Source

pub fn disarm(&self)

Stop watching.

Source

pub fn wait(&self)

Block until all queued and executing callbacks have completed.

Source

pub fn stop_and_drain(&self)

Stop watching and block until no callback is queued or executing.

The same drain ThreadpoolWait::stop_and_drain performs, including suppressing a re-arm a running callback asks for: without that the drain could return with the object armed again, which is the whole reason the standalone type has this method rather than only disarm and wait.

Added because a member that lacked it was not the equivalent of its standalone twin that CleanupGroup::create_wait says it is.

Source

pub fn try_cancel_pending(&self)

Prefer wait.

This crate repairs the pool afterwards – and on a pool whose repair item could not be created, this call tries to create it rather than giving up. Only if that fails too does the cancellation proceed with nothing to repair it, recording cancel-untracked and panicking under fail-fast. That is what makes this safe to offer. See README-FEATURE-self-heal.md.

The registry itself is private, so this names it rather than linking it: a public page linking a private item renders a reference the reader cannot follow, which rustdoc warns about.

Source

pub unsafe fn try_cancel_pending_no_heal_tracking(&self)

try_cancel_pending without the repair.

Not a link, deliberately: the method it would name does not exist in a build with self-heal off, and this one does, so the link would dangle in exactly the configuration this method exists for.

Owning the wait through a cleanup group does not change the hazard. The group’s own Drop is safe because it releases with cancel-pending false, not because the group protects its members; a cancelling release passes the cancel through to each one. Named without a link for the reason given above: close_members_cancelling does not exist in a build with self-heal off, while this method does.

§Safety

The caller must ensure the pool is repaired, by submitting any work item to it or by knowing something else keeps it live. See ThreadpoolWait::try_cancel_pending_no_heal_tracking, whose obligation this is.

Trait Implementations§

Source§

impl<'group> Debug for WaitMember<'group>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for WaitMember<'_>

Source§

impl Sync for WaitMember<'_>

Auto Trait Implementations§

§

impl<'group> Freeze for WaitMember<'group>

§

impl<'group> RefUnwindSafe for WaitMember<'group>

§

impl<'group> Unpin for WaitMember<'group>

§

impl<'group> UnsafeUnpin for WaitMember<'group>

§

impl<'group> UnwindSafe for WaitMember<'group>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.