<div dir="ltr">On Sun, Aug 24, 2008 at 9:25 PM, Per Hedeland <span dir="ltr"><<a href="mailto:per@hedeland.org">per@hedeland.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">"Hynek Vychodil" <<a href="mailto:vychodil.hynek@gmail.com">vychodil.hynek@gmail.com</a>> wrote:<br>
><br>
</div><div class="Ih2E3d">>          {ok, _} = send_after(Time, Ref),<br>
<br>
</div><div class="Ih2E3d">>> It should be much more simpler to do it without modify timer_server:<br>
>><br>
>> sleep(Time) -><br>
>>     case whereis(timer_server) of<br>
>>        undefined -> receive after Time -> ok end;<br>
>>        _ -><br>
>>           Ref = make_ref(),<br>
>>           send_after(Time, Ref),<br>
>>           receive Ref -> ok end<br>
>>     end.<br>
<br>
</div>Matter of taste perhaps, whether you prefer the absolute minimum of<br>
change vs regularity of implementation. One thing that often falls out<br>
of the latter is consistency in API, such that you don't end up with one<br>
API function doing a badmatch crash on erroneous input, while all the<br>
others return {error, badarg}. And of course one could ask why create an<br>
unneeded ref, or why require two messages from the server when you only<br>
need one, but that's more in the nitpicking area.<br>
<font color="#888888"></font></blockquote><div><br>We have had problems with the timer server becoming seriously overloaded. See:<br><br><a href="http://erlang.org/doc/efficiency_guide/commoncaveats.html#3.2">http://erlang.org/doc/efficiency_guide/commoncaveats.html#3.2</a><br>
<br>Therefore, I think that the proper way is to do "receive after" in a try/catch,<br>and only call the timer server if the timeout value is invalid.<br><br>If anyone submits a patch like that, we'll try to include it in R12B-4.<br>
<br>/Bjorn<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888"><br>
--Per Hedeland<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Björn Gustavsson, Erlang/OTP, Ericsson AB<br>
</div>