[erlang-questions] Noob question: Need some help to limit process spawing

avinash D'silva evnix.com@REDACTED
Sun Aug 16 12:44:08 CEST 2015


Hi,

I have these lines code:

 timer:apply_after(5*1000,mymodule,myfunction,[Value]),
 timer:apply_after(5*1000,mymodule,myfunction,[Value]),
 timer:apply_after(5*1000,mymodule,myfunction,[Value]),
 timer:apply_after(5*1000,mymodule,myfunction,[Value]),
 timer:apply_after(5*1000,mymodule,myfunction,[Value]),

"myfunction" looks like this:
myfunction(Value)->

Val2=iolist_to_binary([Value,"_P"]),

case pg2:get_members(Value2) of

        [] ->
            {ok,P}=mymodule:start_link(),
            pg2:join(Value2,P2),
            gen_server:call(P2,{push,Msg});
        Otherwise ->
            [Px|_]=Otherwise,
            gen_server:call(Px,{push,Msg})
      end,

the problem is instead of creating a single process of mymodule.
there are 5 processes, as time taken to register the process is more,

Any solution to this problem?


Regards,
Avinash D' Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150816/42af993d/attachment.htm>


More information about the erlang-questions mailing list