Struct cooper::Actor [−][src]
The Actor.
This is an async command processor that serializes requests around an internal state. Each request runs to completion, atomically, in the order received, and thus tasks do not need to lock or protect the state for access.
Implementations
impl<S> Actor<S> where
S: Default + Send + 'static,
[src]
S: Default + Send + 'static,
impl<S> Actor<S> where
S: Send + 'static,
[src]
S: Send + 'static,
pub fn from_state(state: S) -> Self
[src]
Creates a new actor from an initial state
pub async fn cast<F>(&self, f: F) where
F: for<'a> FnOnce(&'a mut S) -> BoxFuture<'a, ()>,
F: 'static + Send,
[src]
F: for<'a> FnOnce(&'a mut S) -> BoxFuture<'a, ()>,
F: 'static + Send,
This is a totally asynchronous opertion. Awaiting the returned future only waits for the operation to be placed in the queue. It does not wait for the operation to be executed.
pub async fn call<F, R>(&self, f: F) -> R where
F: for<'a> FnOnce(&'a mut S) -> BoxFuture<'a, R>,
F: 'static + Send,
R: 'static + Send + Debug,
[src]
F: for<'a> FnOnce(&'a mut S) -> BoxFuture<'a, R>,
F: 'static + Send,
R: 'static + Send + Debug,
A call is a synchronous opertion within the async task. It will queue the request, wait for it to execute, and return the result.
pub async fn flush(&self)
[src]
Blocks the calling task until all requests up to this point have been processed.
Note that if there are clones of the actor, additional requests may get queued after this one, so the queue is not guaranteed to be empty when this returns; just that all the requests prior to this one have completed.
Trait Implementations
Auto Trait Implementations
impl<S> RefUnwindSafe for Actor<S>
impl<S> Send for Actor<S>
impl<S> Sync for Actor<S>
impl<S> Unpin for Actor<S>
impl<S> UnwindSafe for Actor<S>
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>,