[erlang-questions] Calling multiple processes simultaneously

Torben Hoffmann torben.lehoff@REDACTED
Mon May 23 21:40:19 CEST 2011

Hi Martin,

I would try to avoid overloading the protocol between the program and the
gen_servers - instead I would introduce a gen_sync module  that handles the
synchronisation for you.

The program would provide a list of {M,F,A}'s that all have to be
synchronous calls in your gen_server modules.
The gen_sync module would then spawn a process for each of the {M,F,A}'s and
monitor them for successful completion.
When all processes have returned - either successfully or failed - the
gen_sync call would return with an appropriate answer. Exactly what is
appropriate is up to you.

Yes, this requires another module in your design, but you can re-use it
elsewhere and it provides a nice abstraction for the multi-synchronisation
by pushing all the synchronisation into the gen_sync module.

gen_sync would be a gen_server as far as I can tell, unless you want to
elaborate the functionality and have some states... not sure what those
should be so it is probably overkill.


On Mon, May 23, 2011 at 18:01, Martin Dimitrov <mrtndimitrov@REDACTED>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?
> Regards,
> Martin
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110523/e430cdb9/attachment.htm>

More information about the erlang-questions mailing list