Hi Martin,<div><br></div><div>First of all I try to avoid calls in my systems. I believe that is there is a call - there is a potential lock. Casts are friends.</div><div><br></div><div>In your case I would suggest you to have "special" workers for time consuming operations. Workers should be gen_servers and should be a part of your supervisors tree.</div>
<div><br></div><div>This is just a general suggestion - of course each case is unique. Please adapt it to your case if possible.</div><div><br clear="all"><div><div>Best regards,</div><div>Max</div><br></div><br>
<br><br><div class="gmail_quote">On Wed, Dec 12, 2012 at 1:46 PM, Martin Dimitrov <span dir="ltr"><<a href="mailto:mrtndimitrov@gmail.com" target="_blank">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">
Thanks, this sounds very cool.<br>
<div class="HOEnZb"><div class="h5"><br>
On 12/12/2012 11:42 AM, Attila Rajmund Nohl wrote:<br>
> 2012/12/12 Martin Dimitrov <<a href="mailto:mrtndimitrov@gmail.com">mrtndimitrov@gmail.com</a>>:<br>
>> Hi all,<br>
>><br>
>> In our application, we have a gen_server that does a time consuming<br>
>> operation. The message is of type cast thus the caller process doesn't<br>
>> sit and wait for the operation to finish. But while the gen_server is<br>
>> busy with the cast message, it doesn't serve any other call, right?<br>
>><br>
>> So, would it be appropriate to create a process that will do the time<br>
>> consuming operation and then notify the gen_server?<br>
><br>
> The pattern I use in this case is to still use gen_server:call (if the<br>
> caller needs to be blocked), start a separate process for the<br>
> time-consuming stuff, return {noreply, ...} from the handle_call (so<br>
> the gen_server can handle other calls), then call gen_server:reply<br>
> from the started process when the time-consuming operation finished.<br>
> Of course, the applicability of this pattern depends on what you<br>
> actually do.<br>
><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>
</div></div></blockquote></div><br></div>