Taking over a global name

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Tue Mar 29 22:12:33 CEST 2005


Hi,

Since this is something that isn't easy to test thouroughly, because of all 
the strange race conditions, I hope someone will have a little spare time to 
look at the following code and review it.

The problem to be solved is how to do a takeover between two processes, 
without OTP startup files (as Ulf showed us earlier). One major requirement 
is that no messages should be lost or come out of order.

The code doesn't handle errors, but is supposed to show the bare bones of my 
implementation. Please feel free to criticize, and show simpler 
implementations if they are possible.

The crux lies in takeover/2: the current process should be put on hold (so 
it doesn't eat any more messages), the name is re_registered (the new 
process must be in a special state, so that no messages are eaten), old 
process flushes any messages to the new ones, and then the new one gets to 
run freely.

This is probably very similar to the application start phases described by 
Ulf, but useful if one wants to do it with "simple" processes.

Is there a reason why there isn't a re_register bif for local names?

best regards,
Vlad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: takeover.erl
Type: application/octet-stream
Size: 920 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20050329/1fc4ee6d/attachment.obj>


More information about the erlang-questions mailing list