[erlang-questions] gen_server call and reply

Scott Lystig Fritchie fritchie@REDACTED
Wed Sep 19 02:09:41 CEST 2007


>>>>> "ml" == Matthias Lang <matthias@REDACTED> writes:

ml> Christian S writes:

>> One case that struck my mind is when one spaws a process to do
>> something and return the value with gen_server:reply/2. That
>> requires gen_server:reply/2 to need to be executed before the
>> gen_server:handle_call/3 returns noreply.

ml> That's a good point. That pretty much kills my doubts.

I'm now quite puzzled.  Perhaps I haven't had enough coffee today.

Assume the following two timelines, where time advances as we read
from top to bottom:

    gen_server proc                  helper proc
    ---------------                  -----------
    start executing handle_call/3
    spawn helper proc
                                     do stuff for arbitrary time...
                                     call gen_server:reply/2
    return {noreply, ...}

My understanding of Christian's statement is that this timeline
results in invalid behavior:

    gen_server proc                  helper proc
    ---------------                  -----------
    start executing handle_call/3
    spawn helper proc
                                     do stuff for arbitrary time...
    return {noreply, ...}
                                     call gen_server:reply/2

If my understanding is correct, then Christian's statement is not
correct: the server's apparent behavior will be correct in either
timeline.

-Scott



More information about the erlang-questions mailing list