spawn_many

Function spawn_many 

Source
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>>)
where Fun: FnOnce(I, Inbox<M>) -> Fut + Send + 'static + Clone, Fut: Future<Output = E> + Send + 'static, E: Send + 'static, M: Send + 'static, I: Send + 'static,
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:?}");
        }
    });