@@ -226,8 +226,7 @@ spawn(proc() {
226
226
});
227
227
~~~
228
228
229
- Instead we can use a ` SharedChan ` , a type that allows a single
230
- ` Chan ` to be shared by multiple senders.
229
+ Instead we can clone the ` chan ` , which allows for multiple senders.
231
230
232
231
~~~
233
232
# use std::task::spawn;
@@ -246,16 +245,13 @@ let result = port.recv() + port.recv() + port.recv();
246
245
# fn some_expensive_computation(_i: uint) -> int { 42 }
247
246
~~~
248
247
249
- Here we transfer ownership of the channel into a new ` SharedChan ` value. Like
250
- ` Chan ` , ` SharedChan ` is a non-copyable, owned type (sometimes also referred to
251
- as an * affine* or * linear* type). Unlike with ` Chan ` , though, the programmer
252
- may duplicate a ` SharedChan ` , with the ` clone() ` method. A cloned
253
- ` SharedChan ` produces a new handle to the same channel, allowing multiple
254
- tasks to send data to a single port. Between ` spawn ` , ` Chan ` and
255
- ` SharedChan ` , we have enough tools to implement many useful concurrency
256
- patterns.
248
+ Cloning a ` Chan ` produces a new handle to the same channel, allowing multiple
249
+ tasks to send data to a single port. It also upgrades the channel internally in
250
+ order to allow this functionality, which means that channels that are not
251
+ cloned can avoid the overhead required to handle multiple senders. But this
252
+ fact has no bearing on the channel's usage: the upgrade is transparent.
257
253
258
- Note that the above ` SharedChan ` example is somewhat contrived since
254
+ Note that the above cloning example is somewhat contrived since
259
255
you could also simply use three ` Chan ` pairs, but it serves to
260
256
illustrate the point. For reference, written with multiple streams, it
261
257
might look like the example below.
0 commit comments