[−][src]Struct actix::utils::IntervalFunc
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); } }
Methods
impl<A: Actor> IntervalFunc<A>
[src]
pub fn new<F>(timeout: Duration, f: F) -> IntervalFunc<A> where
F: FnMut(&mut A, &mut A::Context) + 'static,
[src]
F: FnMut(&mut A, &mut A::Context) + 'static,
Creates a new IntervalFunc
with the given interval duration.
Trait Implementations
impl<A: Actor> ActorStream for IntervalFunc<A>
[src]
type Item = ()
The type of item this stream will yield on success.
type Actor = A
The actor within which this stream runs.
fn poll_next(
self: Pin<&mut Self>,
act: &mut Self::Actor,
ctx: &mut <Self::Actor as Actor>::Context,
task: &mut Context
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
act: &mut Self::Actor,
ctx: &mut <Self::Actor as Actor>::Context,
task: &mut Context
) -> Poll<Option<Self::Item>>
fn map<U, F>(self, f: F) -> StreamMap<Self, F> where
F: FnMut(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
Self: Sized,
[src]
F: FnMut(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
Self: Sized,
fn then<F, U>(self, f: F) -> StreamThen<Self, F, U> where
F: FnMut(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
U: IntoActorFuture<Actor = Self::Actor>,
Self: Unpin + Sized,
[src]
F: FnMut(Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> U,
U: IntoActorFuture<Actor = Self::Actor>,
Self: Unpin + Sized,
fn fold<F, T, Fut>(self, init: T, f: F) -> StreamFold<Self, F, Fut, T> where
F: FnMut(T, Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> Fut,
Fut: IntoActorFuture<Actor = Self::Actor, Output = T>,
Self: Sized,
[src]
F: FnMut(T, Self::Item, &mut Self::Actor, &mut <Self::Actor as Actor>::Context) -> Fut,
Fut: IntoActorFuture<Actor = Self::Actor, Output = T>,
Self: Sized,
fn timeout(self, timeout: Duration) -> StreamTimeout<Self> where
Self: Sized + Unpin,
[src]
Self: Sized + Unpin,
fn finish(self) -> StreamFinish<Self> where
Self: Sized + Unpin,
[src]
Self: Sized + Unpin,
Auto Trait Implementations
impl<A> !RefUnwindSafe for IntervalFunc<A>
impl<A> !Send for IntervalFunc<A>
impl<A> !Sync for IntervalFunc<A>
impl<A> Unpin for IntervalFunc<A>
impl<A> !UnwindSafe for IntervalFunc<A>
Blanket Implementations
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,
ⓘImportant traits for &'_ mut Ffn borrow_mut(&mut self) -> &mut T
[src]
ⓘImportant traits for &'_ mut F
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,