Call is a throttling and overload control mechanism.<div><br></div><div>If your worker is too slow you will <span></span>ruine your erlang vm with several millions of casts in the message box<br><br>On Wednesday, December 12, 2012, Martin Dimitrov  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
This is actually a cast but since it takes long the gen_server will be<br>
blocked and I want to avoid this.<br>
<br>
Thanks for the replies,<br>
<br>
Martin<br>
<br>
On 12/12/2012 12:04 PM, Max Bourinov wrote:<br>
> Hi Martin,<br>
><br>
> First of all I try to avoid calls in my systems. I believe that is there is<br>
> a call - there is a potential lock. Casts are friends.<br>
><br>
> In your case I would suggest you to have "special" workers for time<br>
> consuming operations. Workers should be gen_servers and should be a part of<br>
> your supervisors tree.<br>
><br>
> This is just a general suggestion - of course each case is unique. Please<br>
> adapt it to your case if possible.<br>
><br>
> Best regards,<br>
> Max<br>
><br>
><br>
><br>
><br>
> On Wed, Dec 12, 2012 at 1:46 PM, Martin Dimitrov <<a href="javascript:;" onclick="_e(event, 'cvml', 'mrtndimitrov@gmail.com')">mrtndimitrov@gmail.com</a>>wrote:<br>
><br>
>> Thanks, this sounds very cool.<br>
>><br>
>> On 12/12/2012 11:42 AM, Attila Rajmund Nohl wrote:<br>
>>> 2012/12/12 Martin Dimitrov <<a href="javascript:;" onclick="_e(event, 'cvml', '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="javascript:;" onclick="_e(event, 'cvml', '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>
>><br>
><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', '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>