Skip to main content

OperationCompletion

Struct OperationCompletion 

Source
pub struct OperationCompletion { /* private fields */ }
Expand description

The completion signal every operation publishes to when it ends.

This is what lets a caller block until an operation finishes instead of re-checking it on a timer. A worker marks its id finished here as the very last thing it does — after the result is stored, the event emitted, and the final status set — so a waiter woken by it is guaranteed to observe all three. In particular, is_finished(id) == true implies LongOperationManager::get_operation_result already has the result (for a Completed operation), which is what makes an event-free blocking wait correct.

Obtain one via LongOperationManager::completion_signal and block on it after releasing any lock guarding the manager — see that method.

Implementations§

Source§

impl OperationCompletion

Source

pub fn is_finished(&self, id: &str) -> bool

Has id already reached a final status?

Source

pub fn wait_for(&self, id: &str, timeout: Option<Duration>) -> bool

Block until id reaches a final status; true once it has.

There is no lost-wakeup window: the finished-set is inspected while holding the very mutex the condvar is paired with, and a worker must take that same mutex to publish — so an operation that ends between a caller’s check and its wait is already recorded and returns immediately.

timeout bounds one wait, not the whole call, and exists only as a backstop for a signal that can never arrive (e.g. a worker killed before publishing). None waits indefinitely.

Trait Implementations§

Source§

impl Debug for OperationCompletion

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.