pub fn spawn_many<M, E, I, Fun, Fut>(
iter: impl IntoIterator<Item = I>,
config: Config,
fun: Fun,
) -> (ChildPool<E, Channel<M>>, Address<Channel<M>>)Expand description
Spawn a new actor with a multiple process, this returns a ChildPool and an Address.
The iterator will be passed along as the first argument to every spawned function.
ยงExample
let (child_pool, address) =
spawn_many(0..5, Config::default(), |i, mut inbox: Inbox<u32>| async move {
loop {
let msg = inbox.recv().await;
println!("Received message on actor {i}: {msg:?}");
}
});