Using application behaviour to just change a gen event handler
Tue Oct 26 13:38:59 CEST 1999
Sean Hinde <Sean.Hinde@REDACTED> wrote:
> > 2) Create a 'supervisor' with one child which receives a message from
> > alarm_handler if your module crashes. If this happens, this child
> > process calls exit/1, and the supervisor restarts the child, which
> > reinstalls the handler module in alarm_handler.
> > Here's some code to do the trick:
> > /martin
> I used your code with a few changes to allow passing in the handler names as
> startup data (and fixing the loop call arity). Fantastic, thanks.
> Out of interest, why did you choose to implement this as a 'made up'
> behaviour rather than using gen_server. Is the reason performance /
> simplicity, or something subtle to do with the functionality of the startup
> mechanism which can't be achieved using standard behaviours.
No reason at all. You could use Ulf's gen_server based code as well.
[Ok, there must have been a reason somewhere... I probably wrote the
first "gen event supervisor" in the same module as an ordinary
supervisor, (or maybe another gen_server), and I didn't want any more
modules. The recommendation is of course to use a separate module
anyway ;) - modules are cheap!]
More information about the erlang-questions