[erlang-questions] Designing supervision trees
Garrett Smith
g@REDACTED
Wed May 5 20:45:20 CEST 2010
Bernard,
On Wed, May 5, 2010 at 6:01 AM, Alessandro Sivieri
<alessandro.sivieri@REDACTED> wrote:
> 2010/5/4 Garrett Smith <g@REDACTED>
>>
>> I think you'll find different opinions here. I prefer to use
>> supervisors to start and manage processes. If a process needs to
>> "spawn" something, it might make sense to call add_child on an
>> appropriate supervisor. You can create a custom add_xxx_child function
>> on your supervisor module to act somewhat as a factory function.
>>
>> This lets you fire-and-forget (in particular, using
>> simple_one_for_one, which can remove children when they terminate) and
>> avoids messing around with trap_exits in you gen_servers.
>>
>
> This is very interesting, essentially because I am doing the same thing as
> Bernard; but, for what I have understood from the supervisor documentation,
> if I want a child to be supervised, it has to implement one of the four
> behaviours, doesn't it? So, if my child doesn't do that (it is simply a
> process which executes a single function in loop), how can I attach it to a
> supervisor?
I haven't used this, but take a look at:
http://erldocs.com/R13B04/stdlib/gen_server.html?search=gen_server&i=17#enter_loop/5
Garrett
More information about the erlang-questions
mailing list