Skip to content

Commit 5165334

Browse files
committed
---
yaml --- r: 29776 b: refs/heads/incoming c: 8bb5f07 h: refs/heads/master v: v3
1 parent ed806e9 commit 5165334

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 6e311836140f86582501550da249c1df70427ab4
9+
refs/heads/incoming: 8bb5f077c4feb6a2a180810fc16c092bf3532f76
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/pipes.rs

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,40 @@ syntax extension. To see how that works, it is best see comments in
3535
libsyntax/ext/pipes.rs.
3636
3737
This module includes two related pieces of the runtime
38-
implementation. There is support for unbounded and bounded
38+
implementation: support for unbounded and bounded
3939
protocols. The main difference between the two is the type of the
4040
buffer that is carried along in the endpoint data structures.
4141
42-
FIXME (#3072) - This is still incomplete
4342
44-
45-
46-
## Invariants
47-
48-
This section attempts to document the invariants that must hold to
49-
avoid races. These primarily deal with the state and blocked_task
50-
fields on packet_headers.
51-
52-
1. If the sender reads a some(task) out of blocked_task, then the task
53-
that is pointed there will remain live for any events that the sender
54-
might signal.
55-
56-
2. The sender may only read the blocked_task field if it first ensures
57-
that the packet's state field is blocked.
43+
The heart of the implementation is the packet type. It contains a
44+
header and a payload field. Much of the code in this module deals with
45+
the header field. This is where the synchronization information is
46+
stored. In the case of a bounded protocol, the header also includes a
47+
pointer to the buffer the packet is contained in.
48+
49+
Packets represent a single message in a protocol. The payload field
50+
gets instatiated at the type of the message, which is usually an enum
51+
generated by the pipe compiler. Packets are conceptually single use,
52+
although in bounded protocols they are reused each time around the
53+
loop.
54+
55+
56+
Packets are usually handled through a send_packet_buffered or
57+
recv_packet_buffered object. Each packet is referenced by one
58+
send_packet and one recv_packet, and these wrappers enforce that only
59+
one end can send and only one end can receive. The structs also
60+
include a destructor that marks packets are terminated if the sender
61+
or receiver destroys the object before sending or receiving a value.
62+
63+
The *_packet_buffered structs take two type parameters. The first is
64+
the message type for the current packet (or state). The second
65+
represents the type of the whole buffer. For bounded protocols, the
66+
protocol compiler generates a struct with a field for each protocol
67+
state. This generated struct is used as the buffer type parameter. For
68+
unbounded protocols, the buffer is simply one packet, so there is a
69+
shorthand struct called send_packet and recv_packet, where the buffer
70+
type is just `packet<T>`. Using the same underlying structure for both
71+
bounded and unbounded protocols allows for less code duplication.
5872
5973
*/
6074

0 commit comments

Comments
 (0)