timer cleanup in case gen_server crashes

Vance Shipley <>
Fri Sep 3 13:31:31 CEST 2004


Your comments caused me to have a look at gen_fsm.erl as I was
just now using the new built in timers in gen_fsm for the first
time.  They don't seem to do anything special to clean up in the
terminate function.


On Fri, Sep 03, 2004 at 12:43:06PM +0200, Tony Rogvall wrote:
}  I think that the timer bifs are better and more light weight
}  Ref = erlang:set_timer(AfterMilli, Pid, Term) or
}  Ref = erlang:send_after(AfterMilli, Pid, Message)
}  erlang:cancel_timer(Ref)
}  They however must be cleaned up in the terminate function.
}  This is a place for emulator improvement, that is to associate
}  all timers with the receiving process and clean them automatically
}  when that process dies (no point sending timeout to a dead process!)
}  Thanks for pointing that out (indirectly :-)
}  /Tony

More information about the erlang-questions mailing list