[erlang-questions] Noob question: Need some help to limit process spawing
avinash D'silva
evnix.com@REDACTED
Sun Aug 16 15:42:38 CEST 2015
Sorry, it was just a typo.
The original question holds.
I was considering using a *Semaphore* to block the spawning of a new
proccess with the help of ETS, but I fear performance issues.
Code with Fixed Typo:
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(Val2) of
[] ->
{ok,P}=mymodule:start_link(),
pg2:join(Val2,P2),
gen_server:call(P2,{push,Msg});
Otherwise ->
[Px|_]=Otherwise,
gen_server:call(Px,{push,Msg})
end,
On Sun, Aug 16, 2015 at 7:07 PM, Edward Halls <ehalls@REDACTED> wrote:
> Perhaps some better syntax highlighting can help you spot this in the
> future.
>
> A good ide will also tell you when there are unused variables.
> On 16 Aug 2015 2:22 pm, "Robert Raschke" <rtrlists@REDACTED> wrote:
>
>> Could be the typo? Value2 vs Val2.
>> On Aug 16, 2015 12:44 PM, "avinash D'silva" <evnix.com@REDACTED> wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
--
Powered By codologic <http://codologic.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150816/5c7a2d22/attachment.htm>
More information about the erlang-questions
mailing list