[erlang-questions] Trying to use gen_leader and gdict

Jack Orenstein jao@REDACTED
Tue Oct 2 04:09:02 CEST 2007


I am running Erlang R11B on OS X and have been investigating
gen_leader.  I'm having some trouble with the gdict example included
with gen_leader. I wrote the following program to use gdict:

     -module(test).
     -export([main/0]).

     -define(DUMP(X), io:format("~p:~p - ~p = ~p~n", [?MODULE, ? 
LINE, ??X, X])).

     main() ->
         Nodes = [node()],
         {ok, D} = gdict:new(test, Nodes, Nodes),
         ?DUMP(D),
         ?DUMP(gdict:append(a, 1, D)),
         ?DUMP(gdict:append(b, 2, D)),
         ?DUMP(gdict:append(c, 3, D)),
         ?DUMP(gdict:find(a, D)),
         ?DUMP(gdict:find(b, D)),
         ?DUMP(gdict:find(c, D)).

This causes a timeout:

     zack$ time erl -sname z -noshell -s test main -s init stop
     init({dict,0,
                16,
                16,
                8,
                80,
                48,
                {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}})
     {"init terminating in do_boot",{timeout,{gen_leader,leader_call, 
[<0.34.0>,{store,#Fun<gdict.0.10659195>}]}}}

     Crash dump was written to: erl_crash.dump
     init terminating in do_boot ()

     real	0m5.564s
     user	0m0.185s
     sys	0m0.360s

Can anyone see what I'm doing wrong?

Jack Orenstein




More information about the erlang-questions mailing list