Struct actix::utils::TimerFunc[][src]

pub struct TimerFunc<A> where
    A: Actor
{ /* fields omitted */ }
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

Creates a new TimerFunc with the given duration.

Trait Implementations

The type of value that this future will resolved with if it is successful. Read more

The actor within which this future runs

Map this future’s result to a different type, returning a new future of the resulting type. Read more

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more

Add timeout to futures chain. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The future that this type can be converted into.

The item that the future may resolve with.

The actor within which this future runs

Consumes this object and produces a future.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.