[erlang-questions] Atomically replace named process?
Wed Jun 11 20:19:07 CEST 2014
If you are registering the process manually this method will work.
The problem you might run into is the old process dying just before someone is calling it. You would have to cycle off the process by calling unregister manually and wait for some time to handle calls that are still using the old PID.
If your gen_server init looks like this:
case catch register(name) of
Then call, getpid functions:
% The returned PID may get unregistered before it is used.
% This is why the gen_server must unregister and wait for a timeout before dying.
case whereis(name) of
case gen_server:start(….) of
% some other process won the race to register itself.
% this start call won the race
On 11 Jun 2014, at 09:17, Roger Lipscombe <roger@REDACTED> wrote:
> I've got a gen_server with a particular name. I've got a bunch of
> other processes calling and casting to it, by name.
> Can I spin up another gen_server, and have the name transferred
> without anyone noticing? That is: can I redirect the calls and casts
> to the new process without interruption?
> erlang-questions mailing list
More information about the erlang-questions