[erlang-questions] Restarting processes

Daniel Ginsburg dg@REDACTED
Fri Mar 30 13:00:51 CEST 2007


Mats Cronqvist пишет:
> Daniel Ginsburg wrote:
>> Mats Cronqvist пишет:
>>
>>>   i can see two easy ways to do this.
>>>   in either case the workers should monitor the demux.
>>>   * the workers poll on the demux registered name.
>>
>> You mean, calling whereis(demux_name) is a cycle? Well, if other
>> approaches won't work, I think I'll do just that.
> 
>   i'm not sure what you mean by "cycle". but something like (pseudo-code)
> 
> assert_demux() ->
>   case whereis(demux_name) of
>     undefined -> receive after 1000 -> assert_demux() end;
>     Pid -> Pid
>   end.
> 

Yes, that's what I meant.

>>>   * the demux has an ets table with all worker pids, and notify them at
>>> startup.
>>
>> I might be confused about how ets works, but if demux has an ets table
>> and terminates, the table will vanish along with it's owner, won't it?
> 
>   yes, the demux supervisor should own the table.
> 

You mean create ets table in supervisor's init and pass it as argument
to started process in childspec? Neat. I haven't thought about that and
always created my ets tables in my gen_servers' init callback.

>   btw, ulf's "proc" thing is a, quite clever, generalization of this.
> unless you use it, you'll probably end up reinventing it.
> 

Yeah, I'm playing with proc right now and I quite like it. I think I'll
use it.


-- 
dg



More information about the erlang-questions mailing list