Timer

Struct Timer 

Source
pub struct Timer<R> { /* private fields */ }
Expand description

A timer suitable for use by actors.

Implementations§

Source§

impl<R: SupportsTimers> Timer<R>

Source

pub fn new(runtime: R) -> Self

Construct a new timer with the provided runtime.

Source

pub fn state(&self) -> TimerState

Get the state of the timer

Source

pub fn is_active(&self) -> bool

True if this timer is expected to tick in the future.

Source

pub fn clear(&mut self)

Reset the timer to the inactive state.

Source

pub fn tick(&mut self) -> bool

Check if the timer has elapsed.

Source

pub fn set_interval_at_weak<T: Tick>( &mut self, addr: WeakAddr<T>, start: Instant, interval: Duration, )

Configure the timer to tick at a set interval with an initial delay. The timer will not try to keep the actor alive.

Source

pub fn set_interval_at_strong<T: Tick>( &mut self, addr: Addr<T>, start: Instant, interval: Duration, )

Configure the timer to tick at a set interval with an initial delay. The timer will try to keep the actor alive.

Source

pub fn set_interval_weak<T: Tick>( &mut self, addr: WeakAddr<T>, interval: Duration, )

Configure the timer to tick at a set interval, with the initial tick sent immediately. The timer will not try to keep the actor alive.

Source

pub fn set_interval_strong<T: Tick>( &mut self, addr: Addr<T>, interval: Duration, )

Configure the timer to tick at a set interval, with the initial tick sent immediately. The timer will try to keep the actor alive.

Source

pub fn set_timeout_weak<T: Tick>( &mut self, addr: WeakAddr<T>, deadline: Instant, )

Configure the timer to tick once at the specified time. The timer will not try to keep the actor alive.

Source

pub fn set_timeout_strong<T: Tick>(&mut self, addr: Addr<T>, deadline: Instant)

Configure the timer to tick once at the specified time. The timer will try to keep the actor alive until that time.

Source

pub fn set_timeout_for_weak<T: Tick>( &mut self, addr: WeakAddr<T>, duration: Duration, )

Configure the timer to tick once after a delay. The timer will not try to keep the actor alive.

Source

pub fn set_timeout_for_strong<T: Tick>( &mut self, addr: Addr<T>, duration: Duration, )

Configure the timer to tick once after a delay. The timer will try to keep the actor alive until that time.

Source

pub fn run_with_timeout_weak<T: Tick + ?Sized, F: Future<Output = ()> + Send + 'static>( &mut self, addr: WeakAddr<T>, deadline: Instant, f: impl FnOnce(WeakAddr<T>) -> F + Send + 'static, )

Configure the timer to tick once at the specified time, whilst simultaneously running a task to completion. If the timeout completes first, the task will be dropped. The timer will not try to keep the actor alive.

Source

pub fn run_with_timeout_strong<T: Tick + ?Sized, F: Future<Output = ()> + Send + 'static>( &mut self, addr: Addr<T>, deadline: Instant, f: impl FnOnce(Addr<T>) -> F + Send + 'static, )

Configure the timer to tick once at the specified time, whilst simultaneously running a task to completion. If the timeout completes first, the task will be dropped. The timer will try to keep the actor alive until that time.

Source

pub fn run_with_timeout_for_weak<T: Tick + ?Sized, F: Future<Output = ()> + Send + 'static>( &mut self, addr: WeakAddr<T>, duration: Duration, f: impl FnOnce(WeakAddr<T>) -> F + Send + 'static, )

Configure the timer to tick once at the specified time, whilst simultaneously running a task to completion. If the timeout completes first, the task will be dropped. The timer will not try to keep the actor alive.

Source

pub fn run_with_timeout_for_strong<T: Tick + ?Sized, F: Future<Output = ()> + Send + 'static>( &mut self, addr: Addr<T>, duration: Duration, f: impl FnOnce(Addr<T>) -> F + Send + 'static, )

Configure the timer to tick once at the specified time, whilst simultaneously running a task to completion. If the timeout completes first, the task will be dropped. The timer will try to keep the actor alive until that time.

Trait Implementations§

Source§

impl<R: Debug> Debug for Timer<R>

Source§

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

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

impl<R: Default> Default for Timer<R>

Source§

fn default() -> Timer<R>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Timer<R>
where R: Freeze,

§

impl<R> !RefUnwindSafe for Timer<R>

§

impl<R> Send for Timer<R>
where R: Send,

§

impl<R> Sync for Timer<R>
where R: Sync,

§

impl<R> Unpin for Timer<R>
where R: Unpin,

§

impl<R> !UnwindSafe for Timer<R>

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 = 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.