[erlang-questions] on_load

Tony Rogvall tony@REDACTED
Mon Dec 7 16:37:49 CET 2009


Thanks!

I did a RTFM on myself ;-)
As the paragraph is stated I surely created a dead lock.

Maybe I should use a spawn to do what I was thinking of. 

/Tony

On 7 dec 2009, at 11.41, Zoltan Lajos Kis wrote:

> http://www.erlang.org/doc/reference_manual/code_loading.html
> 
> "A process that calls any function in a module whose on_load function has
> not yet returned will be suspended until the on_load function has
> returned."
> 
> Isn't there a deadlock with start() waiting for auto_start() to finish and
> vice versa?
> 
> Regards,
> Zoltan.
> 
> 
>> I am trying the on_load feature.
>> 
>> I did:
>> 
>> -on_load(auto_start/0).
>> 
>> In a generic server code.
>> 
>> Then I defined auto_start as:
>> 
>> %% called when module is loaded
>> auto_start() ->
>>    io:format("auto_start\n"),
>>    Result = start(),
>>    io:format("result = ~p\n", [Result]),
>>    true.
>> 
>> 
>> Where start/0 is the normal:
>> 
>> start() ->
>>    gen_server:start({local, ?SERVER}, ?MODULE, [], []).
>> 
>> Question.
>> 
>> Is this supposed to be working ? Why not?
>> Currently I get the the "auto_start" output and the the gen_server is
>> registered.
>> Apart from that it is hanging.
>> 
>> 
>> /Tony
>> 
>> 
>> ________________________________________________________________
>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>> erlang-questions (at) erlang.org
>> 
>> 
>> 
> 
> 
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 



More information about the erlang-questions mailing list