ensure_started

Luke Gorrie <>
Thu Feb 27 16:24:30 CET 2003


Ulf Wiger <> writes:

> I posted the following suggestion a few weeks ago, now
> slightly modified:
> 
> ensure_started() ->
>    Id = {{?MODULE,ensure_started}, self()},
>    global:trans(
>        Id, fun() ->
>                case whereis(?MODULE) of
>                   undefined ->
>                      Pid = proc_lib:spawn(?MODULE,init,[]),
>                      register(?MODULE, Pid),
>                      {ok, Pid};
>                   Pid when pid(Pid) ->
>                      {ok, Pid}
>                end
>            end, [node()]).
> 
> 
> Since you know that the ensure_started() call is always
> local you can use global:trans(Id, Fun, [node()]) which will
> cut it down to two gen_server calls to the nearest global
> name server.
> 
> (http://www.erlang.org/ml-archive/erlang-questions/200302/msg00391.html)

Sounds like something for the Jungerl, maybe a catchy 'procutil'
module in the 'msc' application?

Can any of you guys at Ericsson get into the Jungerl through your
firewall? If not I'm keen to help sort it out.

Cheers,
Luke




More information about the erlang-questions mailing list