Server handling lots of connections ...

Ulf Wiger ulf@REDACTED
Sat Apr 22 11:40:14 CEST 2006


Den 2006-04-22 02:45:08 skrev Jérémie Lumbroso"" <jeremie@REDACTED>:

> I've seen an astute programmer have the start/1 function create a thread  
> and register it using the atom created by:
> list_to_atom("serverProcess_" ++ integer_to_list(Port)).
> However I've also read that creating atoms like that is not good. Is  
> there something more idiomatic?

1) In the example above, you're creating an atom from a
    finite (in practice) namespace. The BIF list_to_existing_atom/1
    can increase safety somewhat in this case.

2) The proc utility (in jungerl) has semantics similar to
    the local process registry, but allows you to register
    any term. There are of course some drawbacks, for example
    that you can't quite as transparently send a message to
    a process registered in this fashion (it works more like
    global, in that you get to call proc:send(Alias, Msg))

3) You can of course use global in the same way as proc.
    If you have only one node, global will effectively
    work like a local process registry. Both global and
    proc allow you to register a process using any term,
    and also to register more than one alias per process.
    Global is, of course, a standard OTP module. Proc isn't.

BR,
Ulf W

-- 
Ulf Wiger



More information about the erlang-questions mailing list