Struct cooper::ThreadedActor [−][src]
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]
T: Default + Send + 'static,
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]
T: Send + 'static,
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]
F: FnOnce(&mut T) + Send + 'static,
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]
F: FnOnce(&mut T) -> R + Send + 'static,
R: Send + 'static,
Trait Implementations
impl<T: Clone> Clone for ThreadedActor<T>
[src]
fn clone(&self) -> ThreadedActor<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,