Aaron Feng on 22 Oct 2007 14:09:12 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[philly-lambda] Erlang Question

  • From: "Aaron Feng" <aaron.feng@gmail.com>
  • To: philly-lambda@googlegroups.com
  • Subject: [philly-lambda] Erlang Question
  • Date: Mon, 22 Oct 2007 10:08:58 -0400
  • Authentication-results: mx.google.com; spf=pass (google.com: domain of aaron.feng@gmail.com designates as permitted sender) smtp.mail=aaron.feng@gmail.com; dkim=pass (test mode) header.i=@gmail.com
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=1vGnRit6KF8cBefYrm857WkMeYahSbCQ4O1Q9HaUn/0=; b=EUuIfYAPQSO3usYvAE0yoziurqLqI2zoEV1quVialtxPRwPNAPZ1cGPYWOtdSJQCDbwtt6aTEgFVHBIcWxebINpT1v81c44qFFEulTV2318nQHALFBdiar18u1P+9AETu9npdcU/1WMjQP3eB6GyYqOJsR2XGDIBpGTmhqW9Gn0=
  • Mailing-list: list philly-lambda@googlegroups.com; contact philly-lambda-owner@googlegroups.com
  • Reply-to: philly-lambda@googlegroups.com
  • Sender: philly-lambda@googlegroups.com

I posted the following question last night on Erlang's mailing list.  No one seems to know the answer to this question so far.  Maybe someone here would know.

The following code snippet appeared on page 352:

-export([start/0, start_in_shell_for_testing/0, start_link/1, init/1]).

start() ->
  spawn(fun() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, _Arg = [])

start_in_shell_for_testing() ->
  {ok, Pid} = supervisor:start_link({local,?MODULE}, ?MODULE, _Arg = []),

%% rest of the code intentionally left out

What's the benefit of calling spawn on supervisor:start_link in the start() function?  Why not just call supervisor:start_link without the spawn?  Doesn't supervisor:start_link already spawn and register the process already?  In fact, if you use spawn on supervisor:start_link you can't get to the process the supervisor manages, at least I don't know how. 

For example, the supervisor manages two worker processes: area_server and prime_server.  In the shell, the supervisor is started using the start() with the spawn in it.  I'm unable to call the area_server's function using its registered process name.  If I remove the spawn from the start(), I can call area_server's function in the shell. 

Also to notice, the function used to test the supervisor in the shell (start_in_shell_for_testing()) doesn't have the spawn in it.

Thanks in advance,


You received this message because you are subscribed to the Google Groups "Philly Lambda" group.
To unsubscribe from this group, send email to philly-lambda-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/philly-lambda?hl=en