[erlang-questions] Optmized way to handle more timers

Fredrik Andersson sedrik@REDACTED
Wed Mar 16 09:09:15 CET 2011


On Tue, Mar 15, 2011 at 6:55 PM, Jesper Louis Andersen <
jesper.louis.andersen@REDACTED> wrote:

> On Tue, Mar 15, 2011 at 17:09, maruthavanan s
> <maruthavanan_s@REDACTED> wrote:
>
> > I have a situation where my task can fail and I have to retry it after n
> seconds. The situation there may be around 100 timers in a second at the
> worst case. I feel creating 100 timers for this situation is not optimum.
> >
> > Any ideas how to handle this.
>
> With timers? :)
>
> I'd use erlang:send_after/2 or erlang:start_timer/2 to install timers.
> It is quite much faster than the timer module and it should easily be
> able to cope with many simultaneous timers. You can also cancel timers
> again when you know they are not necessary anymore, but do use the
> TimerRef to make sure you don't handle old stray timers. If you are
> using gen_fsm's, then they have their own timers which may come in
> handy for you.
>
>
For more information the *Efficiency Guide** User's Guide (see*
http://erlang.org/doc/efficiency_guide/commoncaveats.html#id60654).

=)


>
>
> --
> J.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list