Function actress::spawn_with_handle
[−]
[src]
pub fn spawn_with_handle<T: Actor + Send + 'static>(
contained: T
) -> (Sender<T::MessageType>, JoinHandle<()>)
Spawns an actor with the given struct instance. Returns a tuple of a channel Sender
to communicate
with the newly-spawned actor as well as a JoinHandle
to later join the actor.
Examples
struct NullActor; impl actress::Actor for NullActor { type MessageType = i32; fn recv(&mut self, msg: i32) -> bool { msg == 42 } } fn main() { let null_actor = NullActor; let (actor, handle) = actress::spawn_with_handle(null_actor); }