Struct cooper::ThreadedActor[][src]

pub struct ThreadedActor<T> { /* fields omitted */ }

An actor that uses an OS thread-per-instance.

This may be useful if the application only needs a few actors and doesn’ otherwise use an async runtime. Or it can be used in an async context if an actor needs to block or is compute intensive and requires its own thread.

Implementations

impl<T> ThreadedActor<T> where
    T: Default + Send + 'static, 
[src]

pub fn new() -> Self[src]

Creates an actor with a default initial state.

This requires the state type to implement the Default trait.

impl<T> ThreadedActor<T> where
    T: Send + 'static, 
[src]

pub fn from_state(state: T) -> Self[src]

Creates a threaded actor with the specified initial state.

pub fn cast<F>(&self, f: F) where
    F: FnOnce(&mut T) + Send + 'static, 
[src]

Send an asynchronous request to the actor.

This queues the request and returns immediately.

pub fn call<F, R>(&self, f: F) -> R where
    F: FnOnce(&mut T) -> R + Send + 'static,
    R: Send + 'static, 
[src]

Trait Implementations

impl<T: Clone> Clone for ThreadedActor<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for ThreadedActor<T>

impl<T> Send for ThreadedActor<T>

impl<T> Sync for ThreadedActor<T>

impl<T> Unpin for ThreadedActor<T>

impl<T> UnwindSafe for ThreadedActor<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.