Trait acto::ActoRuntime
source · pub trait ActoRuntime: Clone + Send + Sync + 'static {
type ActoHandle<O: Send + 'static>: ActoHandle<Output = O>;
type Sender<M: Send + 'static>: Sender<M>;
type Receiver<M: Send + 'static>: Receiver<M>;
// Required methods
fn name(&self) -> &str;
fn mailbox<M: Send + 'static>(&self) -> (Self::Sender<M>, Self::Receiver<M>);
fn spawn_task<T>(
&self,
id: ActoId,
name: SmolStr,
task: T
) -> Self::ActoHandle<T::Output>
where T: Future + Send + 'static,
T::Output: Send + 'static;
// Provided method
fn spawn_actor<M, F, Fut, S>(
&self,
name: &str,
actor: F
) -> SupervisionRef<M, Self::ActoHandle<Fut::Output>>
where M: Send + 'static,
F: FnOnce(ActoCell<M, Self, S>) -> Fut,
Fut: Future + Send + 'static,
Fut::Output: Send + 'static,
S: Send + 'static { ... }
}
Expand description
For implementors: the interface of a runtime for operating actors.
Cloning a runtime should be cheap, it SHOULD be using the Arc<Inner>
pattern.
Required Associated Types§
sourcetype ActoHandle<O: Send + 'static>: ActoHandle<Output = O>
type ActoHandle<O: Send + 'static>: ActoHandle<Output = O>
The type of handle used for joining the actor’s task.
Required Methods§
sourcefn mailbox<M: Send + 'static>(&self) -> (Self::Sender<M>, Self::Receiver<M>)
fn mailbox<M: Send + 'static>(&self) -> (Self::Sender<M>, Self::Receiver<M>)
Create a new pair of sender and receiver for a fresh actor.
sourcefn spawn_task<T>(
&self,
id: ActoId,
name: SmolStr,
task: T
) -> Self::ActoHandle<T::Output>
fn spawn_task<T>( &self, id: ActoId, name: SmolStr, task: T ) -> Self::ActoHandle<T::Output>
Spawn an actor’s task to be driven independently and return an ActoHandle
to abort or join it.
Provided Methods§
sourcefn spawn_actor<M, F, Fut, S>(
&self,
name: &str,
actor: F
) -> SupervisionRef<M, Self::ActoHandle<Fut::Output>>
fn spawn_actor<M, F, Fut, S>( &self, name: &str, actor: F ) -> SupervisionRef<M, Self::ActoHandle<Fut::Output>>
Provided function for spawning actors.
Uses the above utilities and cannot be implemented by downstream crates.
Object Safety§
This trait is not object safe.
Implementors§
source§impl ActoRuntime for AcTokioRuntime
Available on crate feature tokio
only.
impl ActoRuntime for AcTokioRuntime
Available on crate feature
tokio
only.