[erlang-questions] Timers for hibernated processes

Scott Lystig Fritchie fritchie@REDACTED
Wed Nov 23 00:15:03 CET 2011

Hi, I'm going to make a tongue-in-cheek suggestion that may be a
horrible idea or may be great.

Imagine a registered process for a timeout interval of N seconds.
Someone interested in receiving a message every N seconds would monitor

N seconds after the process is spawned, the 'wacky_timer_N' process

    1. create a new process whose sole job is to become the new
    'wacky_timer-N' process

    2. exit({new_wacky_timer_N_pid, pid-from-step#1})

Every process that has a monitor will get the message when step #2
happens.  If a process is interested in recurring timers, it can use the
NewPid found in the {'DOWN', ... {new_wacky_timer_N_pid, NewPid}}
message directly.

It'd be interesting to see how long it would take to propagate 500K
'DOWN' messages.  Having looked fairly recently at the code for
propagating monitor messages, the answer is probably "too long", but if
someone wants to experiement, it'd be interesting to hear the results.


More information about the erlang-questions mailing list