Struct actix::utils::IntervalFunc [−][src]
#[must_use = "future do nothing unless polled"]pub struct IntervalFunc<A: Actor> { /* fields omitted */ }
Expand description
An ActorStream
that periodically runs a function in the actor’s context.
Unless you specifically need access to the future, use Context::run_interval
instead.
use std::time::Duration; use actix::prelude::*; use actix::utils::IntervalFunc; struct MyActor; impl MyActor { fn tick(&mut self, context: &mut Context<Self>) { println!("tick"); } } impl Actor for MyActor { type Context = Context<Self>; fn started(&mut self, context: &mut Context<Self>) { // spawn an interval stream into our context IntervalFunc::new(Duration::from_millis(100), Self::tick) .finish() .spawn(context); } }
Implementations
Trait Implementations
Auto Trait Implementations
impl<A> !RefUnwindSafe for IntervalFunc<A>
impl<A> !Send for IntervalFunc<A>
impl<A> !Sync for IntervalFunc<A>
impl<A> !UnwindSafe for IntervalFunc<A>
Blanket Implementations
Maps this stream’s items to a different type, returning a new stream of the resulting type. Read more
Computes from this stream’s items new items of a different type using an asynchronous closure. Read more
Execute an accumulating asynchronous computation over a stream, collecting all the values into one final result. Read more
Take elements from this stream while the provided asynchronous predicate
resolves to true
. Read more
Skip elements on this stream while the provided asynchronous predicate
resolves to true
. Read more
Add timeout to stream. Read more
Transforms a stream into a collection, returning a future representing the result of that computation. Read more
Mutably borrows from an owned value. Read more