Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: docs/intro/message_pipes.md

Issue 1762503002: Add some docs about mojom (files/IDL). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Message pipes 1 # Message pipes
2 2
3 Message pipes are the primary communication mechanism between Mojo programs. A 3 Message pipes are the primary communication mechanism between Mojo programs. A
4 *message pipe* is a point-to-point (with each side being called a message pipe 4 *message pipe* is a point-to-point (with each side being called a message pipe
5 *endpoint*), bidirectional message passing mechanism, where messages may contain 5 *endpoint*), bidirectional message passing mechanism, where messages may contain
6 both data and Mojo handles. 6 both data and Mojo handles.
7 7
8 It's important to understand that a message pipe is a "transport": it provides a 8 It's important to understand that a message pipe is a "transport": it provides a
9 way for data and handles to be sent between Mojo programs. The system is unaware 9 way for data and handles to be sent between Mojo programs. The system is unaware
10 of the meaning of the data or of the handles (other than their intrinsic 10 of the meaning of the data or of the handles (other than their intrinsic
11 properties). 11 properties).
12 12
13 That said, Mojo provides a *standard* way of communicating over message pipes, 13 That said, Mojo provides a *standard* way of communicating over message pipes,
14 namely via a standardized protocol together with [Mojom](mojom.md) IDL files. 14 namely via a standardized protocol together with [Mojom IDL](mojom_idl.md)
15 files.
15 16
16 ## Messages 17 ## Messages
17 18
18 A *message* consists of two things: 19 A *message* consists of two things:
19 * a finite sequence of bytes, and 20 * a finite sequence of bytes, and
20 * a finite sequence of [Mojo handles](handles.md). 21 * a finite sequence of [Mojo handles](handles.md).
21 22
22 Both of these are determined when the message is sent (or *written*). Messages 23 Both of these are determined when the message is sent (or *written*). Messages
23 are *framed* in the sense that they are "atomic" units: they are sent and 24 are *framed* in the sense that they are "atomic" units: they are sent and
24 received (or *read*) as entire units, not just by Mojo programs themselves but 25 received (or *read*) as entire units, not just by Mojo programs themselves but
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 76
76 ## "Synchronous" operation 77 ## "Synchronous" operation
77 78
78 Though message pipes are asynchronous as discussed above, they may be used in a 79 Though message pipes are asynchronous as discussed above, they may be used in a
79 synchronous fashion: immediately after sending a *request* message, one can then 80 synchronous fashion: immediately after sending a *request* message, one can then
80 just block and wait for the *response* message (and then read it and process 81 just block and wait for the *response* message (and then read it and process
81 it). Of course, this requires that the protocol support this: 82 it). Of course, this requires that the protocol support this:
82 * Message pipes must be used in a "directional" way: there must be fixed request 83 * Message pipes must be used in a "directional" way: there must be fixed request
83 and response directions or, equivalently, one endpoint belongs to the *client* 84 and response directions or, equivalently, one endpoint belongs to the *client*
84 and the other to the *server* (or *impl*). (Historical note: This is the case 85 and the other to the *server* (or *impl*). (Historical note: This is the case
85 for the current Mojom protocol, but not in previous versions.) The issue here 86 for the current [Mojom protocol](mojom_protocol.md), but not in previous
86 is that without this, the sender of the request messages may have to process 87 versions.) The issue here is that without this, the sender of the request
87 incoming request messages from its peer. 88 messages may have to process incoming request messages from its peer.
88 * Request messages must have unique response messages. (In the Mojom protocol, 89 * Request messages must have unique response messages. (In the Mojom protocol,
89 request messages have optional unique responses. For messages without 90 request messages have optional unique responses. For messages without
90 responses, one can just proceed immediately without waiting. However, without 91 responses, one can just proceed immediately without waiting. However, without
91 response messages there may be flow control issues; again, see above.) The 92 response messages there may be flow control issues; again, see above.) The
92 important point is that for each request message, there is a well-defined 93 important point is that for each request message, there is a well-defined
93 number of response messages for each request and not arbitrary "callback" 94 number of response messages for each request and not arbitrary "callback"
94 messages. 95 messages.
95 * The sending of a response message must not depend on a future action of the 96 * The sending of a response message must not depend on a future action of the
96 client. (This is a higher-level semantic that is not enforced by the Mojom 97 client. (This is a higher-level semantic that is not enforced by the Mojom
97 protocol. E.g., one may define a Mojom interface in which the response to a 98 protocol. E.g., one may define a Mojom interface in which the response to a
(...skipping 11 matching lines...) Expand all
109 result in deadlock. (E.g., this is the usual programming model for the 110 result in deadlock. (E.g., this is the usual programming model for the
110 standard Mojom C++ bindings.) 111 standard Mojom C++ bindings.)
111 * Even when blocking is permissible, it may not be desirable to do so: 112 * Even when blocking is permissible, it may not be desirable to do so:
112 advancement of the program then relies on trusting the server to be 113 advancement of the program then relies on trusting the server to be
113 responsive and send responses in a timely fashion. 114 responsive and send responses in a timely fashion.
114 * Mixing asynchronous and synchronous operation is problematic: one cannot send 115 * Mixing asynchronous and synchronous operation is problematic: one cannot send
115 a request and synchronously wait for a response while responses to other 116 a request and synchronously wait for a response while responses to other
116 messages are still pending. (Theoretically, one could buffer such other 117 messages are still pending. (Theoretically, one could buffer such other
117 responses until the response to particular request is received, and process 118 responses until the response to particular request is received, and process
118 those other responses later, but this would be dubious at best.) 119 those other responses later, but this would be dubious at best.)
OLDNEW
« no previous file with comments | « docs/intro/intro.md ('k') | docs/intro/mojom.md » ('j') | docs/intro/mojom_idl.md » ('J')

Powered by Google App Engine
This is Rietveld 408576698