Struct actix::utils::TimerFunc [−][src]
An ActorFuture
that runs a function in the actor’s context after a specified amount of time.
Unless you specifically need access to the future, use Context::run_later
instead.
use std::time::Duration; use actix::prelude::*; use actix::utils::TimerFunc; struct MyActor; impl MyActor { fn stop(&mut self, context: &mut Context<Self>) { System::current().stop(); } } impl Actor for MyActor { type Context = Context<Self>; fn started(&mut self, context: &mut Context<Self>) { // spawn a delayed future into our context TimerFunc::new(Duration::from_millis(100), Self::stop) .spawn(context); } }
Implementations
impl<A: Actor> TimerFunc<A>
[src]
pub fn new<F>(timeout: Duration, f: F) -> TimerFunc<A> where
F: FnOnce(&mut A, &mut A::Context) + 'static,
[src]
F: FnOnce(&mut A, &mut A::Context) + 'static,
Creates a new TimerFunc
with the given duration.
Trait Implementations
impl<A> ActorFuture<A> for TimerFunc<A> where
A: Actor,
[src]
A: Actor,
type Output = ()
The type of value that this future will resolved with if it is successful. Read more
fn poll(
self: Pin<&mut Self>,
act: &mut A,
ctx: &mut A::Context,
task: &mut Context<'_>
) -> Poll<Self::Output>
[src]
self: Pin<&mut Self>,
act: &mut A,
ctx: &mut A::Context,
task: &mut Context<'_>
) -> Poll<Self::Output>
impl<'__pin, A: Actor> Unpin for TimerFunc<A> where
__Origin<'__pin, A>: Unpin,
[src]
__Origin<'__pin, A>: Unpin,
Auto Trait Implementations
impl<A> !RefUnwindSafe for TimerFunc<A>
impl<A> !Send for TimerFunc<A>
impl<A> !Sync for TimerFunc<A>
impl<A> !UnwindSafe for TimerFunc<A>
Blanket Implementations
impl<F, A> ActorFutureExt<A> for F where
F: ActorFuture<A>,
A: Actor,
[src]
F: ActorFuture<A>,
A: Actor,
fn map<Fn, U>(self, f: Fn) -> Map<Self, Fn> where
Fn: FnOnce(Self::Output, &mut A, &mut A::Context) -> U,
Self: Sized,
[src]
Fn: FnOnce(Self::Output, &mut A, &mut A::Context) -> U,
Self: Sized,
fn then<Fn, Fut>(self, f: Fn) -> Then<Self, Fut, Fn> where
Fn: FnOnce(Self::Output, &mut A, &mut A::Context) -> Fut,
Fut: IntoActorFuture<A>,
Self: Sized,
[src]
Fn: FnOnce(Self::Output, &mut A, &mut A::Context) -> Fut,
Fut: IntoActorFuture<A>,
Self: Sized,
fn timeout(self, timeout: Duration) -> Timeout<Self> where
Self: Sized,
[src]
Self: Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<F, A> IntoActorFuture<A> for F where
F: ActorFuture<A>,
A: Actor,
[src]
F: ActorFuture<A>,
A: Actor,
type Future = F
The future that this type can be converted into.
type Output = <F as ActorFuture<A>>::Output
The item that the future may resolve with.
pub fn into_future(Self) -> F
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,