pub struct TimerFunc<A: Actor> { /* private fields */ }
Expand description
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§
Trait Implementations§
Source§impl<A> ActorFuture<A> for TimerFunc<A>where
A: Actor,
impl<A> ActorFuture<A> for TimerFunc<A>where
A: Actor,
impl<'__pin, A: Actor> Unpin for TimerFunc<A>where
PinnedFieldsOf<__Origin<'__pin, A>>: Unpin,
Auto Trait Implementations§
impl<A> !Freeze for TimerFunc<A>
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§
Source§impl<F, A> ActorFutureExt<A> for Fwhere
F: ActorFuture<A>,
A: Actor,
impl<F, A> ActorFutureExt<A> for Fwhere
F: ActorFuture<A>,
A: Actor,
Source§fn map<F, U>(self, f: F) -> Map<Self, F>
fn map<F, U>(self, f: F) -> Map<Self, F>
Map this future’s result to a different type, returning a new future of
the resulting type.
Source§fn then<F, Fut>(self, f: F) -> Then<Self, Fut, F>
fn then<F, Fut>(self, f: F) -> Then<Self, Fut, F>
Chain on a computation for when a future finished, passing the result of
the future to the provided closure
f
.Source§fn timeout(self, timeout: Duration) -> Timeout<Self>where
Self: Sized,
fn timeout(self, timeout: Duration) -> Timeout<Self>where
Self: Sized,
Add timeout to futures chain. Read more
Source§fn boxed_local(self) -> LocalBoxActorFuture<A, Self::Output>where
Self: Sized + 'static,
fn boxed_local(self) -> LocalBoxActorFuture<A, Self::Output>where
Self: Sized + 'static,
Wrap the future in a Box, pinning it. Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more