[erlang-questions] puzzle about gen_server:call/2

litao cheng <>
Tue Sep 23 03:39:37 CEST 2008


thank you! Ulf W.


2008/9/22 Ulf Wiger <>

> It is possible to return {noreply, NewState} in cases when
> e.g. the request triggers a background job. The server can
> then reply later with gen_server:reply(From, Reply), and
> be free to handle other requests in the meantime.
>
> BR,
> Ulf W
>
> 2008/9/22 litao cheng <>:
> > Greetings !
> > I read the codes of gen_server.erl and gen.erl in stdlib, the
> > gen_server:call/3 invoke process is illustrated as follows:
> >
> > gen_server:call/3 ->
> > gen:call/3 ->
> > gen:call/4 ->
> > gen:do_call/4
> >
> > in the gen:do_call/4, first check if the target Process is exist by
> invoke
> > erlang:monitor/2, if the process is alive then send the message,
> > after the messge is sended, invoke the  wait_resp_mon/3 to wait the
> > response, if the Mod:handle_call return {reply, Reply, State}, then in
> > wait_resp_mon/3, we can receive the message and return the Reply to the
> > gen_server:call/2 caller. My Question is: If the Mod:handle_call return
> > {noreply, State}, then I see the gen_server continue the loop, not send
> any
> > message to caller, in that case I think the wait_resp_mon/3 will be
> blocked,
> > Factually I know the caller not block! Anyone can give me a explain?
> >
> > thanks!
> > Best Regards!
> >
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080923/5b62c308/attachment.html>


More information about the erlang-questions mailing list