[erlang-questions] Associating contextual info with monitors

Dave Smith dizzyd@REDACTED
Mon Feb 18 03:52:56 CET 2008


Greetings,

On several occasions, I've found myself wanting to be able to do some
cleanup (e.g. remove an entry in ets) when a process dies. Usually I
solve this by maintaining an ets table keyed by pid, that stores the
necessary contextual info needed for cleanup, and then setup a monitor
on the pid of interest. This works ok, but it's a little annoying to
need to maintain yet another ets table for this context info that is
only used when the process dies. It seems like what I _really_ want is
a way to associate a term with a monitor -- that way when I get the
DOWN message, I would also get the associated term and have everything
I need to do the cleanup.

Is there a "Right Way" to accomplish this? Maintaining ets tables for
this sort of contextual info seems a bit overkill -- is there a
simpler approach? Has anyone else ever encountered this sort of issue?
I tried searching through the archives for this problem, but couldn't
find the right set of search terms. :)

Thanks,

D.



More information about the erlang-questions mailing list