[erlang-questions] Custom supervisor

Edwin Fine erlang-questions_efine@REDACTED
Sun Jan 18 18:50:05 CET 2009


Just a thought: instead of trying to pattern match all the possible
responses from anything that returns {ok, arg0, arg1,...,argN}, how about
using element()?

e.g.

start_child(Id, Args) ->
    case supervisor:start_child(work_super,
                   {Id, {work, start_link, Args},
                   transient, 60*1000, worker, [work]}) of
           T when T =:= ok; element(1, T) =:= ok ->
               ok;
           {error, {already_started, _Child}} ->
               ok;
           Error ->
               Error
       end.



> start_child(Id, Args) ->
>        case supervisor:start_child(work_super,
>                        {Id, {work, start_link, Args},
>                        transient, 60*1000, worker, [work]}) of
>                {ok, _Child} ->
>                        ok;
>                {ok, _Child, _Info} ->
>                        ok;
>                {error, {already_started, _Child}} ->
>                        ok;
>                Error ->
>                        Error
>        end.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090118/8f47099b/attachment.htm>


More information about the erlang-questions mailing list