[erlang-questions] Registering a process with multiple names

Ulf Wiger <>
Thu Jan 22 21:06:55 CET 2009


Take a look at gproc (google for gproc and Wiger). It does what you
want. A simpler version can also be found in jungerl (called proc or
proc_reg - I can't recall).

BR,
Ulf W (via cell phone)

2009/1/22, Torben Hoffmann <>:
> Hi,
>
> I have implemented a protocol stack and the current implementation has a
> coordinator process that keeps track of the processes that are spawned to
> handle the individual calls (very telcom protocol).
>
> The reason for this is that I have two types of call identifies: one at the
> top of the stack that represents my connection to our legacy system and one
> at the bottom of the stack that represents the protocol's call.
>
> When I get a message from our legacy system my coordinator process looks up
> in its list of spawned processes and finds the process for that message
> based on the legacy call identifier.
>
> Likewise when I get a message from the protocol: the call identifier is used
> by the coordinator to find the process to send the message to.
>
> In my ideal world I would like to register the call process with two names:
> one for the legacy call identificator and on for the protocol's call
> identificator.
> Then my coordinator could look up if a process has been spawned for a call
> identificator (legacy or protocol) and then forward the message.
> If there hasn't been spawned a process for the call the coordinator spawns a
> new one and registers it.
>
> The problem is that erlang:register/2 barfs if you try to register a process
> more than once.
>
> Surely I am not the first to run into this type of problem so I am hoping
> that the someone has some ideas for me!
>
> Thanks in advance,
> Torben
>



More information about the erlang-questions mailing list