Modules function in Erlang -
so, here part of module i'm writing:
request(pid, listofdocuments) when is_pid(pid), is_list(listofdocuments) -> io:format("we here~n"), case whereis(jdw_api) of undefined -> [no, api]; apipid when is_pid(apipid) -> io:format("... , here~n"), % (1) won't work: spawn(?module, loop, [pid, listofdocuments]) % (2) won't work, either: ?module:loop(pid, listofdocuments) loop(pid, listofdocuments) % (3) , neither this... end.
... , this:
loop(pid, docs) when is_list(docs), length(docs) > 0 -> h = hd(docs), t = tl(docs), io:format("... not here...~w~n", h), case ?mode of sync -> ref = make_ref(), jdw_api ! {self(), ref, doc, h}, ans = loop_sync(ref, [], []), pid ! ans, loop(pid, t); async -> {error, 'async mode not implemented yet', ?file, ?line}; _ -> {'?mode must either async or sync'} end; loop(pid, docs) -> io:format("done document list").
... reason, "loop" function never gets called. neither of 3 different ways makes magic happen... pointers?
your loop function might called, code show above 1 clause of function, , run if called pid , non-empty list of documents. other problem buggy call io:format("... not here...~w~n", h)
should io:format("... not here...~w~n", [h])
. call might crashing loop code. without more source work , example arguments request/2
it's hard tell.
Comments
Post a Comment