pub fn spawn_many<M, E, I, Fun, Fut>(
    iter: impl IntoIterator<Item = I>,
    config: Config,
    fun: Fun
) -> (ChildPool<E, Channel<M>>, Address<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 Processes. This will return a ChildPool and and Address. The Processes are spawned with Inboxes.

The amount of Processes that are spawned is equal to the length of the iterator. Every process get’s access to a single item within the iterator as it’s first argument.

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:?}");
        }
    });