Hi Martin,<br><br>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.<br><br>The program would provide a list of {M,F,A}'s that all have to be synchronous calls in your gen_server modules.<br>
The gen_sync module would then spawn a process for each of the {M,F,A}'s and monitor them for successful completion.<br>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.<br>
<br>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.<br><br>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.<br>
<br>Cheers,<br>Torben<br><br><br><div class="gmail_quote">On Mon, May 23, 2011 at 18:01, Martin Dimitrov <span dir="ltr"><<a href="mailto:mrtndimitrov@gmail.com">mrtndimitrov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, please, advise on this one,<br>
<br>
We have several hundred processes (gen_servers) . At one point the<br>
program has to send them a message that needs to be handled before the<br>
calling process can continue executing. This naturally led us to use<br>
gen_server:call in loop over the processes.<br>
<br>
I started to wonder if there is a more efficient way of doing it since<br>
the calling process doesn’t care about the return value – just needs to<br>
be sure that all processes had handled the message. Can we somehow call<br>
the processes simultaneously? Something similar to gen_server:multi_call<br>
but for one node with different processes?<br>
<br>
Regards,<br>
<br>
Martin<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.linkedin.com/in/torbenhoffmann">http://www.linkedin.com/in/torbenhoffmann</a><br>