Skip to content

Commit 3771b90

Browse files
committed
---
yaml --- r: 163685 b: refs/heads/snap-stage3 c: f6328b6 h: refs/heads/master i: 163683: bd81f1b v: v3
1 parent 07e30af commit 3771b90

File tree

338 files changed

+16151
-7941
lines changed

Some content is hidden

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

338 files changed

+16151
-7941
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: cbe9fb45bc705a89f23b434c686544d490923596
4+
refs/heads/snap-stage3: f6328b60da4c506f0f15dc0194f9b9a89aa61a79
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/crates.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std flate arena term \
5353
serialize getopts collections test time rand \
54-
log regex graphviz core rbml alloc \
54+
log regex graphviz core rbml alloc rustrt \
5555
unicode
5656
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_driver rustc_trans rustc_back rustc_llvm
5757
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc regex_macros fmt_macros
@@ -62,8 +62,9 @@ DEPS_core :=
6262
DEPS_libc := core
6363
DEPS_unicode := core
6464
DEPS_alloc := core libc native:jemalloc
65-
DEPS_std := core libc rand alloc collections unicode \
66-
native:rust_builtin native:backtrace native:rustrt_native
65+
DEPS_rustrt := alloc core libc collections native:rustrt_native
66+
DEPS_std := core libc rand alloc collections rustrt unicode \
67+
native:rust_builtin native:backtrace
6768
DEPS_graphviz := std
6869
DEPS_syntax := std term serialize log fmt_macros arena libc
6970
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::io;
3232
use std::os;
3333
use std::str;
3434
use std::string::String;
35-
use std::thread::Thread;
35+
use std::task;
3636
use std::time::Duration;
3737
use test::MetricMap;
3838

@@ -445,9 +445,9 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
445445
loop {
446446
//waiting 1 second for gdbserver start
447447
timer::sleep(Duration::milliseconds(1000));
448-
let result = Thread::spawn(move || {
448+
let result = task::try(move || {
449449
tcp::TcpStream::connect("127.0.0.1:5039").unwrap();
450-
}).join();
450+
});
451451
if result.is_err() {
452452
continue;
453453
}

branches/snap-stage3/src/doc/guide-tasks.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
% The Rust Tasks and Communication Guide
22

3-
**NOTE** This guide is badly out of date an needs to be rewritten.
4-
53
# Introduction
64

75
Rust provides safe concurrent abstractions through a number of core library
@@ -24,7 +22,7 @@ from shared mutable state.
2422
At its simplest, creating a task is a matter of calling the `spawn` function
2523
with a closure argument. `spawn` executes the closure in the new task.
2624

27-
```{rust,ignore}
25+
```{rust}
2826
# use std::task::spawn;
2927
3028
// Print something profound in a different task using a named function
@@ -51,7 +49,7 @@ closure is limited to capturing `Send`-able data from its environment
5149
ensures that `spawn` can safely move the entire closure and all its
5250
associated state into an entirely different task for execution.
5351

54-
```{rust,ignore}
52+
```{rust}
5553
# use std::task::spawn;
5654
# fn generate_task_number() -> int { 0 }
5755
// Generate some state locally
@@ -77,7 +75,7 @@ The simplest way to create a channel is to use the `channel` function to create
7775
of a channel, and a **receiver** is the receiving endpoint. Consider the following
7876
example of calculating two results concurrently:
7977

80-
```{rust,ignore}
78+
```{rust}
8179
# use std::task::spawn;
8280
8381
let (tx, rx): (Sender<int>, Receiver<int>) = channel();
@@ -98,15 +96,15 @@ stream for sending and receiving integers (the left-hand side of the `let`,
9896
`(tx, rx)`, is an example of a destructuring let: the pattern separates a tuple
9997
into its component parts).
10098

101-
```{rust,ignore}
99+
```{rust}
102100
let (tx, rx): (Sender<int>, Receiver<int>) = channel();
103101
```
104102

105103
The child task will use the sender to send data to the parent task, which will
106104
wait to receive the data on the receiver. The next statement spawns the child
107105
task.
108106

109-
```{rust,ignore}
107+
```{rust}
110108
# use std::task::spawn;
111109
# fn some_expensive_computation() -> int { 42 }
112110
# let (tx, rx) = channel();
@@ -125,7 +123,7 @@ computation, then sends the result over the captured channel.
125123
Finally, the parent continues with some other expensive computation, then waits
126124
for the child's result to arrive on the receiver:
127125

128-
```{rust,ignore}
126+
```{rust}
129127
# fn some_other_expensive_computation() {}
130128
# let (tx, rx) = channel::<int>();
131129
# tx.send(0);
@@ -156,7 +154,7 @@ spawn(move || {
156154

157155
Instead we can clone the `tx`, which allows for multiple senders.
158156

159-
```{rust,ignore}
157+
```{rust}
160158
let (tx, rx) = channel();
161159
162160
for init_val in range(0u, 3) {
@@ -181,7 +179,7 @@ Note that the above cloning example is somewhat contrived since you could also
181179
simply use three `Sender` pairs, but it serves to illustrate the point. For
182180
reference, written with multiple streams, it might look like the example below.
183181

184-
```{rust,ignore}
182+
```{rust}
185183
# use std::task::spawn;
186184
187185
// Create a vector of ports, one for each child task
@@ -205,7 +203,7 @@ getting the result later.
205203

206204
The basic example below illustrates this.
207205

208-
```{rust,ignore}
206+
```{rust}
209207
use std::sync::Future;
210208
211209
# fn main() {
@@ -232,7 +230,7 @@ called.
232230
Here is another example showing how futures allow you to background
233231
computations. The workload will be distributed on the available cores.
234232

235-
```{rust,ignore}
233+
```{rust}
236234
# use std::num::Float;
237235
# use std::sync::Future;
238236
fn partial_sum(start: uint) -> f64 {
@@ -270,7 +268,7 @@ Here is a small example showing how to use Arcs. We wish to run concurrently
270268
several computations on a single large vector of floats. Each task needs the
271269
full vector to perform its duty.
272270

273-
```{rust,ignore}
271+
```{rust}
274272
use std::num::Float;
275273
use std::rand;
276274
use std::sync::Arc;
@@ -297,7 +295,7 @@ The function `pnorm` performs a simple computation on the vector (it computes
297295
the sum of its items at the power given as argument and takes the inverse power
298296
of this value). The Arc on the vector is created by the line:
299297

300-
```{rust,ignore}
298+
```{rust}
301299
# use std::rand;
302300
# use std::sync::Arc;
303301
# fn main() {
@@ -311,7 +309,7 @@ the wrapper and not its contents. Within the task's procedure, the captured
311309
Arc reference can be used as a shared reference to the underlying vector as
312310
if it were local.
313311

314-
```{rust,ignore}
312+
```{rust}
315313
# use std::rand;
316314
# use std::sync::Arc;
317315
# fn pnorm(nums: &[f64], p: uint) -> f64 { 4.0 }
@@ -348,17 +346,17 @@ and `()`, callers can pattern-match on a result to check whether it's an `Ok`
348346
result with an `int` field (representing a successful result) or an `Err` result
349347
(representing termination with an error).
350348

351-
```{rust,ignore}
352-
# use std::thread::Thread;
349+
```{rust}
350+
# use std::task;
353351
# fn some_condition() -> bool { false }
354352
# fn calculate_result() -> int { 0 }
355-
let result: Result<int, Box<std::any::Any + Send>> = Thread::spawn(move || {
353+
let result: Result<int, Box<std::any::Any + Send>> = task::try(move || {
356354
if some_condition() {
357355
calculate_result()
358356
} else {
359357
panic!("oops!");
360358
}
361-
}).join();
359+
});
362360
assert!(result.is_err());
363361
```
364362

branches/snap-stage3/src/doc/guide.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,8 +5217,6 @@ the same function, so our binary is a little bit larger.
52175217
52185218
# Tasks
52195219
5220-
**NOTE**: this section is currently out of date and will be rewritten soon.
5221-
52225220
Concurrency and parallelism are topics that are of increasing interest to a
52235221
broad subsection of software developers. Modern computers are often multi-core,
52245222
to the point that even embedded devices like cell phones have more than one
@@ -5233,7 +5231,7 @@ library, and not part of the language. This means that in the future, other
52335231
concurrency libraries can be written for Rust to help in specific scenarios.
52345232
Here's an example of creating a task:
52355233
5236-
```{rust,ignore}
5234+
```{rust}
52375235
spawn(move || {
52385236
println!("Hello from a task!");
52395237
});
@@ -5263,7 +5261,7 @@ If tasks were only able to capture these values, they wouldn't be very useful.
52635261
Luckily, tasks can communicate with each other through **channel**s. Channels
52645262
work like this:
52655263
5266-
```{rust,ignore}
5264+
```{rust}
52675265
let (tx, rx) = channel();
52685266
52695267
spawn(move || {
@@ -5282,7 +5280,7 @@ which returns an `Result<T, TryRecvError>` and does not block.
52825280
52835281
If you want to send messages to the task as well, create two channels!
52845282
5285-
```{rust,ignore}
5283+
```{rust}
52865284
let (tx1, rx1) = channel();
52875285
let (tx2, rx2) = channel();
52885286
@@ -5342,7 +5340,7 @@ we'll just get the value immediately.
53425340
Tasks don't always succeed, they can also panic. A task that wishes to panic
53435341
can call the `panic!` macro, passing a message:
53445342
5345-
```{rust,ignore}
5343+
```{rust}
53465344
spawn(move || {
53475345
panic!("Nope.");
53485346
});
@@ -5351,7 +5349,7 @@ spawn(move || {
53515349
If a task panics, it is not possible for it to recover. However, it can
53525350
notify other tasks that it has panicked. We can do this with `task::try`:
53535351
5354-
```{rust,ignore}
5352+
```{rust}
53555353
use std::task;
53565354
use std::rand;
53575355

branches/snap-stage3/src/doc/intro.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,11 @@ safe concurrent programs.
389389
Here's an example of a concurrent Rust program:
390390
391391
```{rust}
392-
use std::thread::Thread;
393-
394392
fn main() {
395393
for _ in range(0u, 10u) {
396-
Thread::spawn(move || {
394+
spawn(move || {
397395
println!("Hello, world!");
398-
}).detach();
396+
});
399397
}
400398
}
401399
```
@@ -405,8 +403,7 @@ This program creates ten threads, who all print `Hello, world!`. The
405403
double bars `||`. (The `move` keyword indicates that the closure takes
406404
ownership of any data it uses; we'll have more on the significance of
407405
this shortly.) This closure is executed in a new thread created by
408-
`spawn`. The `detach` method means that the child thread is allowed to
409-
outlive its parent.
406+
`spawn`.
410407
411408
One common form of problem in concurrent programs is a 'data race.'
412409
This occurs when two different threads attempt to access the same
@@ -421,15 +418,13 @@ problem.
421418
Let's see an example. This Rust code will not compile:
422419
423420
```{rust,ignore}
424-
use std::thread::Thread;
425-
426421
fn main() {
427422
let mut numbers = vec![1i, 2i, 3i];
428423

429424
for i in range(0u, 3u) {
430-
Thread::spawn(move || {
425+
spawn(move || {
431426
for j in range(0, 3) { numbers[j] += 1 }
432-
}).detach();
427+
});
433428
}
434429
}
435430
```
@@ -474,21 +469,20 @@ mutation doesn't cause a data race.
474469
Here's what using an Arc with a Mutex looks like:
475470
476471
```{rust}
477-
use std::thread::Thread;
478472
use std::sync::{Arc,Mutex};
479473
480474
fn main() {
481475
let numbers = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
482476
483477
for i in range(0u, 3u) {
484478
let number = numbers.clone();
485-
Thread::spawn(move || {
479+
spawn(move || {
486480
let mut array = number.lock();
487481
488482
(*array)[i] += 1;
489483
490484
println!("numbers[{}] is {}", i, (*array)[i]);
491-
}).detach();
485+
});
492486
}
493487
}
494488
```
@@ -538,15 +532,13 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
538532
safety check that makes this an error about moved values:
539533
540534
```{rust,ignore}
541-
use std::thread::Thread;
542-
543535
fn main() {
544536
let vec = vec![1i, 2, 3];
545537
546538
for i in range(1u, 3) {
547-
Thread::spawn(move || {
539+
spawn(move || {
548540
println!("{}", vec[i]);
549-
}).detach();
541+
});
550542
}
551543
}
552544
```

branches/snap-stage3/src/liballoc/arc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use heap::deallocate;
3939
///
4040
/// ```rust
4141
/// use std::sync::Arc;
42-
/// use std::thread::Thread;
4342
///
4443
/// fn main() {
4544
/// let numbers = Vec::from_fn(100, |i| i as f32);
@@ -48,11 +47,11 @@ use heap::deallocate;
4847
/// for _ in range(0u, 10) {
4948
/// let child_numbers = shared_numbers.clone();
5049
///
51-
/// Thread::spawn(move || {
50+
/// spawn(move || {
5251
/// let local_numbers = child_numbers.as_slice();
5352
///
5453
/// // Work with the local numbers
55-
/// }).detach();
54+
/// });
5655
/// }
5756
/// }
5857
/// ```

branches/snap-stage3/src/libcollections/binary_heap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
//! use std::collections::BinaryHeap;
3030
//! use std::uint;
3131
//!
32-
//! #[deriving(Copy, Eq, PartialEq)]
32+
//! #[deriving(Eq, PartialEq)]
3333
//! struct State {
3434
//! cost: uint,
3535
//! position: uint
3636
//! }
3737
//!
38+
//! impl Copy for State {}
39+
//!
3840
//! // The priority queue depends on `Ord`.
3941
//! // Explicitly implement the trait so the queue becomes a min-heap
4042
//! // instead of a max-heap.

branches/snap-stage3/src/libcollections/btree/set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ mod test {
762762
expected: &'b [int],
763763
}
764764

765-
impl<'a, 'b, 'c> FnMut(&'c int) -> bool for Counter<'a, 'b> {
766-
extern "rust-call" fn call_mut(&mut self, (&x,): (&'c int,)) -> bool {
765+
impl<'a, 'b> FnMut(&int) -> bool for Counter<'a, 'b> {
766+
extern "rust-call" fn call_mut(&mut self, (&x,): (&int,)) -> bool {
767767
assert_eq!(x, self.expected[*self.i]);
768768
*self.i += 1;
769769
true

0 commit comments

Comments
 (0)