[erlang-questions] [LONG] How to make synchronous message passing

ZeD vito.detullio@REDACTED
Wed Oct 3 08:53:21 CEST 2007


Richard Carlsson wrote:

>> synchro(P, {do, Q, {ask, P}}).
> It seems that you are not talking about normal synchronous communication,
> but rather a form of nested request/reply. In synchronous message passing,
> if P is waiting for a reply from Q then he is by definition blocked and
> cannot answer the query from Q. Your implementation in synchro2 is
> correct, but synchronous communication is not what you need for this
> problem. You have to rethink what f does.

mmm

maybe I made a wrong example, or maybe you are right (effectively using
asinchronous communications I can have a reply)... let me change the
question:

if a process P want to make a synchronous call to Q, then it send a message 
and waits for a reply.

What's appened when another process, R (just for make and example) send a
message to P 'before' the Q reply?
In particular, what if Q first send another message to P, then waits for the
reply, and only after all this, send the reply to the original message to
P?

Oh, and just to know, let's say P was described by the function f(), which
have a receive; now P want to talk to Q, then now the behavior of P is
described by synchro2(), wich also have a receive. Let's say P finally had
a reply, so the control came back to f(). What append to messages not
matched by synchro2()? they became automatically "receveived" by f()? They
get lost?

-- 
Under construction




More information about the erlang-questions mailing list