simple_one_for_one worker

tty <>
Fri Jul 1 16:38:23 CEST 2005


Bengt Kleberg wrote:

> any one of the callback modules 3 handle_* functions (handle_call/3, 
> handle_cast/2, handle_info/2) can return a tuple with the first member 
> equal to stop (eg {stop,Reason,Reply,NewState} for handle_call/3).
> 

Unfortunately it does not answer my question. 

I am aware of those callback however who should call them ? Should the Supervisor do that after calling supervisor:terminate_child ? Or does supervisor:terminate_child call one of the handle_* functions. 

Furthur more since my gen_server process should terminate after it is done processing does this imply it should call supervisor:terminate_child on itself ?

Basically the architecture I have in mind looks like:

                        supervisor
                 /          |              \
              worker1    worker2  . . .  workerN

where worker1 ... workerN are all from the same module. In a non-OTP world I would just do a spawn_link to create the workers and the running process would be *non* recursive i.e. it terminate on the final statement.

Thanks

tee






More information about the erlang-questions mailing list