[erlang-questions] Calling multiple processes simultaneously

Mihai Balea mihai@REDACTED
Mon May 23 18:13:28 CEST 2011


On May 23, 2011, at 12:01 PM, Martin Dimitrov wrote:

> Hi, please, advise on this one,
> 
> We have several hundred processes (gen_servers) . At one point the
> program has to send them a message that needs to be handled before the
> calling process can continue executing. This naturally led us to use
> gen_server:call in loop over the processes.
> 
> I started to wonder if there is a more efficient way of doing it since
> the calling process doesn’t care about the return value – just needs to
> be sure that all processes had handled the message. Can we somehow call
> the processes simultaneously? Something similar to gen_server:multi_call
> but for one node with different processes?


You could do gen_server:cast in a loop, then wait for all servers to send a "message handled" response back to your main process.
There's no built in way to do this, as far as I know, so you'll have to implement the cast and wait loops manually.

Mihai


More information about the erlang-questions mailing list