Skip to main content

Lifecycle

Struct Lifecycle 

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

Tracks work started by a generated mediator.

Generated code registers every event worker and #[medi_task] before it is spawned, and marks it complete when its future returns. Self::wait is therefore the completion guarantee used by mediator shutdown.

Implementations§

Source§

impl Lifecycle

Source

pub const fn new() -> Self

Create an idle lifecycle tracker.

Source

pub fn start(&self) -> Result<(), StartError>

Mark the mediator as started.

Returns StartError::AlreadyStarted if another caller has already started it. This operation is atomic across concurrent callers.

Source

pub fn is_started(&self) -> bool

Return whether the mediator has been started.

Source

pub fn request_shutdown(&self) -> bool

Request shutdown, returning true only for the caller that initiated it.

Source

pub fn begin(&self)

Register work immediately before spawning it.

Source

pub fn finish(&self)

Mark previously registered work as complete.

Source

pub fn wait(&self) -> impl Future<Output = ()> + '_

Wait until all registered workers and tasks have returned.

Trait Implementations§

Source§

impl Default for Lifecycle

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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.