Skip to content

Commit 00be2e0

Browse files
committed
---
yaml --- r: 105341 b: refs/heads/master c: edb6b02 h: refs/heads/master i: 105339: 3229c5d v: v3
1 parent 73966ea commit 00be2e0

File tree

158 files changed

+2068
-2251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+2068
-2251
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d367482491ab82af8cc88f2f822fef725237cfbe
2+
refs/heads/master: edb6b025c48205c5084a648c7ef7859adbf5c705
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13

trunk/src/compiletest/compiletest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#[allow(non_camel_case_types)];
1414
#[deny(warnings)];
15-
#[allow(deprecated_owned_vector)];
1615

1716
extern crate test;
1817
extern crate getopts;

trunk/src/doc/guide-tasks.md

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ concurrency at this writing:
4848
* [`std::task`] - All code relating to tasks and task scheduling,
4949
* [`std::comm`] - The message passing interface,
5050
* [`sync::DuplexStream`] - An extension of `pipes::stream` that allows both sending and receiving,
51-
* [`sync::SyncSender`] - An extension of `pipes::stream` that provides synchronous message sending,
52-
* [`sync::SyncReceiver`] - An extension of `pipes::stream` that acknowledges each message received,
51+
* [`sync::SyncChan`] - An extension of `pipes::stream` that provides synchronous message sending,
52+
* [`sync::SyncPort`] - An extension of `pipes::stream` that acknowledges each message received,
5353
* [`sync::rendezvous`] - Creates a stream whose channel, upon sending a message, blocks until the
5454
message is received.
5555
* [`sync::Arc`] - The Arc (atomically reference counted) type, for safely sharing immutable data,
@@ -70,8 +70,8 @@ concurrency at this writing:
7070
[`std::task`]: std/task/index.html
7171
[`std::comm`]: std/comm/index.html
7272
[`sync::DuplexStream`]: sync/struct.DuplexStream.html
73-
[`sync::SyncSender`]: sync/struct.SyncSender.html
74-
[`sync::SyncReceiver`]: sync/struct.SyncReceiver.html
73+
[`sync::SyncChan`]: sync/struct.SyncChan.html
74+
[`sync::SyncPort`]: sync/struct.SyncPort.html
7575
[`sync::rendezvous`]: sync/fn.rendezvous.html
7676
[`sync::Arc`]: sync/struct.Arc.html
7777
[`sync::RWArc`]: sync/struct.RWArc.html
@@ -141,115 +141,118 @@ receiving messages. Pipes are low-level communication building-blocks and so
141141
come in a variety of forms, each one appropriate for a different use case. In
142142
what follows, we cover the most commonly used varieties.
143143

144-
The simplest way to create a pipe is to use the `channel`
145-
function to create a `(Sender, Receiver)` pair. In Rust parlance, a *sender*
146-
is a sending endpoint of a pipe, and a *receiver* is the receiving
144+
The simplest way to create a pipe is to use `Chan::new`
145+
function to create a `(Port, Chan)` pair. In Rust parlance, a *channel*
146+
is a sending endpoint of a pipe, and a *port* is the receiving
147147
endpoint. Consider the following example of calculating two results
148148
concurrently:
149149

150150
~~~~
151151
# use std::task::spawn;
152152
153-
let (tx, rx): (Sender<int>, Receiver<int>) = channel();
153+
let (port, chan): (Port<int>, Chan<int>) = Chan::new();
154154
155155
spawn(proc() {
156156
let result = some_expensive_computation();
157-
tx.send(result);
157+
chan.send(result);
158158
});
159159
160160
some_other_expensive_computation();
161-
let result = rx.recv();
161+
let result = port.recv();
162162
# fn some_expensive_computation() -> int { 42 }
163163
# fn some_other_expensive_computation() {}
164164
~~~~
165165

166166
Let's examine this example in detail. First, the `let` statement creates a
167167
stream for sending and receiving integers (the left-hand side of the `let`,
168-
`(tx, rx)`, is an example of a *destructuring let*: the pattern separates
168+
`(chan, port)`, is an example of a *destructuring let*: the pattern separates
169169
a tuple into its component parts).
170170

171171
~~~~
172-
let (tx, rx): (Sender<int>, Receiver<int>) = channel();
172+
let (port, chan): (Port<int>, Chan<int>) = Chan::new();
173173
~~~~
174174

175-
The child task will use the sender to send data to the parent task,
176-
which will wait to receive the data on the receiver. The next statement
175+
The child task will use the channel to send data to the parent task,
176+
which will wait to receive the data on the port. The next statement
177177
spawns the child task.
178178

179179
~~~~
180180
# use std::task::spawn;
181181
# fn some_expensive_computation() -> int { 42 }
182-
# let (tx, rx) = channel();
182+
# let (port, chan) = Chan::new();
183183
spawn(proc() {
184184
let result = some_expensive_computation();
185-
tx.send(result);
185+
chan.send(result);
186186
});
187187
~~~~
188188

189-
Notice that the creation of the task closure transfers `tx` to the child
190-
task implicitly: the closure captures `tx` in its environment. Both `Sender`
191-
and `Receiver` are sendable types and may be captured into tasks or otherwise
189+
Notice that the creation of the task closure transfers `chan` to the child
190+
task implicitly: the closure captures `chan` in its environment. Both `Chan`
191+
and `Port` are sendable types and may be captured into tasks or otherwise
192192
transferred between them. In the example, the child task runs an expensive
193193
computation, then sends the result over the captured channel.
194194

195195
Finally, the parent continues with some other expensive
196196
computation, then waits for the child's result to arrive on the
197-
receiver:
197+
port:
198198

199199
~~~~
200200
# fn some_other_expensive_computation() {}
201-
# let (tx, rx) = channel::<int>();
202-
# tx.send(0);
201+
# let (port, chan) = Chan::<int>::new();
202+
# chan.send(0);
203203
some_other_expensive_computation();
204-
let result = rx.recv();
204+
let result = port.recv();
205205
~~~~
206206

207-
The `Sender` and `Receiver` pair created by `channel` enables efficient
207+
The `Port` and `Chan` pair created by `Chan::new` enables efficient
208208
communication between a single sender and a single receiver, but multiple
209-
senders cannot use a single `Sender` value, and multiple receivers cannot use a
210-
single `Receiver` value. What if our example needed to compute multiple
211-
results across a number of tasks? The following program is ill-typed:
209+
senders cannot use a single `Chan`, and multiple receivers cannot use a single
210+
`Port`. What if our example needed to compute multiple results across a number
211+
of tasks? The following program is ill-typed:
212212

213213
~~~ {.ignore}
214+
# use std::task::{spawn};
214215
# fn some_expensive_computation() -> int { 42 }
215-
let (tx, rx) = channel();
216+
let (port, chan) = Chan::new();
216217
217218
spawn(proc() {
218-
tx.send(some_expensive_computation());
219+
chan.send(some_expensive_computation());
219220
});
220221
221-
// ERROR! The previous spawn statement already owns the sender,
222+
// ERROR! The previous spawn statement already owns the channel,
222223
// so the compiler will not allow it to be captured again
223224
spawn(proc() {
224-
tx.send(some_expensive_computation());
225+
chan.send(some_expensive_computation());
225226
});
226227
~~~
227228

228-
Instead we can clone the `tx`, which allows for multiple senders.
229+
Instead we can clone the `chan`, which allows for multiple senders.
229230

230231
~~~
231-
let (tx, rx) = channel();
232+
# use std::task::spawn;
233+
234+
let (port, chan) = Chan::new();
232235
233236
for init_val in range(0u, 3) {
234237
// Create a new channel handle to distribute to the child task
235-
let child_tx = tx.clone();
238+
let child_chan = chan.clone();
236239
spawn(proc() {
237-
child_tx.send(some_expensive_computation(init_val));
240+
child_chan.send(some_expensive_computation(init_val));
238241
});
239242
}
240243
241-
let result = rx.recv() + rx.recv() + rx.recv();
244+
let result = port.recv() + port.recv() + port.recv();
242245
# fn some_expensive_computation(_i: uint) -> int { 42 }
243246
~~~
244247

245-
Cloning a `Sender` produces a new handle to the same channel, allowing multiple
246-
tasks to send data to a single receiver. It upgrades the channel internally in
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
247250
order to allow this functionality, which means that channels that are not
248251
cloned can avoid the overhead required to handle multiple senders. But this
249252
fact has no bearing on the channel's usage: the upgrade is transparent.
250253

251254
Note that the above cloning example is somewhat contrived since
252-
you could also simply use three `Sender` pairs, but it serves to
255+
you could also simply use three `Chan` pairs, but it serves to
253256
illustrate the point. For reference, written with multiple streams, it
254257
might look like the example below.
255258

@@ -258,16 +261,16 @@ might look like the example below.
258261
# use std::vec;
259262
260263
// Create a vector of ports, one for each child task
261-
let rxs = vec::from_fn(3, |init_val| {
262-
let (tx, rx) = channel();
264+
let ports = vec::from_fn(3, |init_val| {
265+
let (port, chan) = Chan::new();
263266
spawn(proc() {
264-
tx.send(some_expensive_computation(init_val));
267+
chan.send(some_expensive_computation(init_val));
265268
});
266-
rx
269+
port
267270
});
268271
269272
// Wait on each port, accumulating the results
270-
let result = rxs.iter().fold(0, |accum, rx| accum + rx.recv() );
273+
let result = ports.iter().fold(0, |accum, port| accum + port.recv() );
271274
# fn some_expensive_computation(_i: uint) -> int { 42 }
272275
~~~
273276

@@ -278,7 +281,7 @@ later.
278281
The basic example below illustrates this.
279282

280283
~~~
281-
extern crate sync;
284+
# extern crate sync;
282285
283286
# fn main() {
284287
# fn make_a_sandwich() {};
@@ -339,10 +342,9 @@ Here is a small example showing how to use Arcs. We wish to run concurrently sev
339342
a single large vector of floats. Each task needs the full vector to perform its duty.
340343

341344
~~~
342-
extern crate rand;
343-
extern crate sync;
344-
345-
use std::vec;
345+
# extern crate sync;
346+
extern crate rand;
347+
# use std::vec;
346348
use sync::Arc;
347349
348350
fn pnorm(nums: &~[f64], p: uint) -> f64 {
@@ -356,11 +358,11 @@ fn main() {
356358
let numbers_arc = Arc::new(numbers);
357359
358360
for num in range(1u, 10) {
359-
let (tx, rx) = channel();
360-
tx.send(numbers_arc.clone());
361+
let (port, chan) = Chan::new();
362+
chan.send(numbers_arc.clone());
361363
362364
spawn(proc() {
363-
let local_arc : Arc<~[f64]> = rx.recv();
365+
let local_arc : Arc<~[f64]> = port.recv();
364366
let task_numbers = local_arc.get();
365367
println!("{}-norm = {}", num, pnorm(task_numbers, num));
366368
});
@@ -393,8 +395,8 @@ and a clone of it is sent to each task
393395
# fn main() {
394396
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>());
395397
# let numbers_arc = Arc::new(numbers);
396-
# let (tx, rx) = channel();
397-
tx.send(numbers_arc.clone());
398+
# let (port, chan) = Chan::new();
399+
chan.send(numbers_arc.clone());
398400
# }
399401
~~~
400402

@@ -410,9 +412,9 @@ Each task recovers the underlying data by
410412
# fn main() {
411413
# let numbers=vec::from_fn(1000000, |_| rand::random::<f64>());
412414
# let numbers_arc=Arc::new(numbers);
413-
# let (tx, rx) = channel();
414-
# tx.send(numbers_arc.clone());
415-
# let local_arc : Arc<~[f64]> = rx.recv();
415+
# let (port, chan) = Chan::new();
416+
# chan.send(numbers_arc.clone());
417+
# let local_arc : Arc<~[f64]> = port.recv();
416418
let task_numbers = local_arc.get();
417419
# }
418420
~~~
@@ -484,18 +486,19 @@ proceed).
484486

485487
A very common thing to do is to spawn a child task where the parent
486488
and child both need to exchange messages with each other. The
487-
function `sync::comm::duplex` supports this pattern. We'll
489+
function `sync::comm::DuplexStream()` supports this pattern. We'll
488490
look briefly at how to use it.
489491

490-
To see how `duplex` works, we will create a child task
492+
To see how `DuplexStream()` works, we will create a child task
491493
that repeatedly receives a `uint` message, converts it to a string, and sends
492494
the string in response. The child terminates when it receives `0`.
493495
Here is the function that implements the child task:
494496

495497
~~~
496-
extern crate sync;
498+
# extern crate sync;
497499
# fn main() {
498-
fn stringifier(channel: &sync::DuplexStream<~str, uint>) {
500+
# use sync::DuplexStream;
501+
fn stringifier(channel: &DuplexStream<~str, uint>) {
499502
let mut value: uint;
500503
loop {
501504
value = channel.recv();
@@ -517,10 +520,10 @@ response itself is simply the stringified version of the received value,
517520
Here is the code for the parent task:
518521
519522
~~~
520-
extern crate sync;
523+
# extern crate sync;
521524
# use std::task::spawn;
522525
# use sync::DuplexStream;
523-
# fn stringifier(channel: &sync::DuplexStream<~str, uint>) {
526+
# fn stringifier(channel: &DuplexStream<~str, uint>) {
524527
# let mut value: uint;
525528
# loop {
526529
# value = channel.recv();
@@ -530,7 +533,7 @@ extern crate sync;
530533
# }
531534
# fn main() {
532535

533-
let (from_child, to_child) = sync::duplex();
536+
let (from_child, to_child) = DuplexStream::new();
534537

535538
spawn(proc() {
536539
stringifier(&to_child);

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ syn keyword rustTrait MutableVector MutableTotalOrdVector
9696
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector
9797

9898
"syn keyword rustFunction stream
99-
syn keyword rustTrait Sender Receiver
99+
syn keyword rustTrait Port Chan
100100
"syn keyword rustFunction spawn
101101

102102
syn keyword rustSelf self

trunk/src/libarena/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#[license = "MIT/ASL2"];
2222
#[allow(missing_doc)];
2323
#[feature(managed_boxes)];
24-
#[allow(deprecated_owned_vector)];
2524

2625
extern crate collections;
2726

0 commit comments

Comments
 (0)