1
1
#[ doc(
2
2
brief = "Communication between tasks" ,
3
- desc = "Communication between tasks is facilitated by ports (in the\
4
- receiving task), and channels (in the sending task). Any\
5
- number of channels may feed into a single port.\
6
- Ports and channels may only transmit values of unique\
7
- types; that is, values that are statically guaranteed to\
8
- be accessed by a single 'owner' at a time. Unique types\
9
- include scalars, vectors, strings, and records, tags,\
10
- tuples and unique boxes (~T) thereof. Most notably,\
11
- shared boxes (@T) may not be transmitted across channels.\
12
- Example:\
13
- let p = comm::port();\
14
- task::spawn(comm::chan(p), fn (c: chan< str>) {\
15
- comm::send(c, \" Hello, World\" );\
16
- });\
3
+ desc = "Communication between tasks is facilitated by ports (in the \
4
+ receiving task), and channels (in the sending task). Any \
5
+ number of channels may feed into a single port. \
6
+ Ports and channels may only transmit values of unique \
7
+ types; that is, values that are statically guaranteed to \
8
+ be accessed by a single 'owner' at a time. Unique types \
9
+ include scalars, vectors, strings, and records, tags, \
10
+ tuples and unique boxes (~T) thereof. Most notably, \
11
+ shared boxes (@T) may not be transmitted across channels. \
12
+ Example: \
13
+ let p = comm::port(); \
14
+ task::spawn(comm::chan(p), fn (c: chan< str>) { \
15
+ comm::send(c, \" Hello, World\" ); \
16
+ }); \
17
17
io::println(comm::recv(p));"
18
18
) ] ;
19
19
@@ -82,18 +82,18 @@ resource port_ptr<T: send>(po: *rustrt::rust_port) {
82
82
}
83
83
84
84
#[ doc(
85
- brief = "A communication endpoint that can receive messages.\
85
+ brief = "A communication endpoint that can receive messages. \
86
86
Ports receive messages from channels.",
87
- desc = "Each port has a unique per-task identity and may not\
88
- be replicated or transmitted. If a port value is\
89
- copied, both copies refer to the same port.\
87
+ desc = "Each port has a unique per-task identity and may not \
88
+ be replicated or transmitted. If a port value is \
89
+ copied, both copies refer to the same port. \
90
90
Ports may be associated with multiple <chan>s."
91
91
) ]
92
92
tag port<T : send> { port_t ( @port_ptr<T >) ; }
93
93
94
94
#[ doc(
95
- brief = "Sends data over a channel. The sent data is moved\
96
- into the channel, whereupon the caller loses\
95
+ brief = "Sends data over a channel. The sent data is moved \
96
+ into the channel, whereupon the caller loses \
97
97
access to it."
98
98
) ]
99
99
fn send< T : send > ( ch : chan < T > , -data : T ) {
@@ -114,8 +114,8 @@ fn port<T: send>() -> port<T> {
114
114
}
115
115
116
116
#[ doc(
117
- brief = "Receive from a port.\
118
- If no data is available on the port then the task will\
117
+ brief = "Receive from a port. \
118
+ If no data is available on the port then the task will \
119
119
block until data becomes available."
120
120
) ]
121
121
fn recv < T : send > ( p : port < T > ) -> T { recv_ ( * * * p) }
0 commit comments