[erlang-questions] Erlang way for process-as-library?
Robert Virding
robert.virding@REDACTED
Tue Feb 6 22:53:00 CET 2007
Torbjorn Tornkvist wrote:
> Either let the users of the library start it with
> a start function or you could let every function
> do it automatically. Example:
>
> start() ->
> case whereis(my_service) of
> Pid when pid(Pid) -> Pid
> _ -> spawn(my_mod, my_server, [])
> end.
That start function is not safe, especially on an SMP system. You could
get two rocesses running start simultaneously both not finding the
server and both trying to start it.
Robert
More information about the erlang-questions
mailing list