2016-07-24 34 views
0

似乎调用add_location主管:start_child回报孩子,不确定

-module(test_sup). 
-version(1.0). 
-behaviour(supervisor). 

-export([start_link/0,add_location/3]). 

-export([init/1]). 

-define(SERVER, ?MODULE). 

start_link() -> 
    supervisor:start_link({local,?SERVER}, ?MODULE, no_args). 

add_location(SupPid, Spaces, Occupied) -> 
    supervisor:start_child(SupPid, child(test_location, [Spaces, Occupied])). 

init(no_args) -> 
    {ok, {{rest_for_one, 5, 2000}, []}}. 

child(Module, Args) -> 
    {Module, {Module, start_link, Args}, 
    permanent, brutal_kill, worker, [Module]}. 

我叫....

{_, SupPid} = test_sup:start_link(). 
{Success, LocRef} = test_sup:add_location(SupPid, 1, 0) 

时,但add_location总是返回一个错误将在运行到一个问题..

{child,undefined,test_location, 
      {test_location,start_link,[1,0]}, 
      permanent,brutal_kill,worker, 
      [zc_pickup_location]}} 

任何想法为什么?

回答

0

我的错误 - test_location中的方法start_link返回了管理员不理解的内容。