IPDL/Getting started: Difference between revisions

Line 246: Line 246:


=== RPC semantics ===
=== RPC semantics ===
"RPC" stands for "remote procedure call," and this third semantics models procedure call semantics.  A quick summary of the difference between RPC and sync semantics is that RPC allows "re-entrant" message handlers --- that is, while an actor is blocked waiting for an "answer" to an RPC "call", it can be ''unblocked'' to handle a new, incoming RPC ''call''.
In the example protocol below, the child actor offers a "CallMeCallYou()" RPC interface, and the parent offers a "CallYou()" RPC interface.  The <code>'''rpc'''</code> qualifiers mean that if the parent calls "CallMeCallYou()" on the child actor, then the child actor, while servicing this call, is allowed to call back into the parent actor's "CallYou()" message.
rpc protocol Example {
child:
    rpc CallMeCallYou() return (int rv);
parent:
    rpc CallYou() returns (int rv);
};
If this were instead a sync protocol, the child actor would not be allowed to call the parent actor's "CallYou()" method while servicing the "CallMeCallYou()" message.  (The child actor would be terminated with extreme prejudice.)
'''TODO''' sequence diagram if this explanation is unclear


=== Preferred semantics ===
=== Preferred semantics ===
Confirmed users
699

edits