pub fn spawn_one<M, E, Fun, Fut>(
config: Config,
fun: Fun
) -> (ChildPool<E, Channel<M>>, Address<M>) where
Fun: FnOnce(Inbox<M>) -> Fut + Send + 'static,
Fut: Future<Output = E> + Send + 'static,
E: Send + 'static,
M: Send + 'static,
Expand description
Same as spawn, but returns a ChildPool instead of a Child.
let (child_pool, address) =
spawn_one(Config::default(), |mut inbox: Inbox<u32>| async move {
loop {
let msg = inbox.recv().await;
println!("Received message: {msg:?}");
}
});