Fri Nov 7 15:40:13 CET 2014
On Wednesday, November 05, Tony Rogvall wrote:
> I propose a new BIF:
> erlang:restart_timer(Ref, Time) -> false | RemainingTime
> What about it? I'd like to hear from people actually implementing
> protocols, not only from the "normal" responders.
TL;DR: Looks logical, will make some of my code slightly simpler, but
I don't have enough of this code for it to make a practical
difference. All the code where performance really matters is in C,
assembler or in an FPGA.
I took a look through my production (i.e. not side projects or tests) code.
I have two places in my Erlang code which use the pattern you
described, i.e. a recurring event (e.g. receiving a packet) resets a
timer; the timer is "always" running. Neither is performance-sensitive.
I have far more places in the code where I do something and start a timer
in case the operation hangs. There's no restarting in that situation.
Most of those timers are of the 'receive....after' sort.
I also took a look through Vance Shipley's LAPD code. I can't find a git
repo of it, but here's a google code one:
As far as I can see (I took a quick look), all the timers it uses are
the 'gen_fsm' ones, i.e. he calls gen_fsm:cancel_timer(). One example
is LAPD T203, the maximum time allowed without a frame. It gets reset
every time you send a packet.
More information about the erlang-questions