Skip to content

Commit caca9b2

Browse files
committed
Fallout from stabilization
1 parent f67b81e commit caca9b2

File tree

97 files changed

+245
-248
lines changed

Some content is hidden

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

97 files changed

+245
-248
lines changed

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
447447
loop {
448448
//waiting 1 second for gdbserver start
449449
timer::sleep(Duration::milliseconds(1000));
450-
let result = Thread::spawn(move || {
450+
let result = Thread::scoped(move || {
451451
tcp::TcpStream::connect("127.0.0.1:5039").unwrap();
452452
}).join();
453453
if result.is_err() {

src/doc/intro.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ fn main() {
395395
for _ in range(0u, 10u) {
396396
Thread::spawn(move || {
397397
println!("Hello, world!");
398-
}).detach();
398+
});
399399
}
400400
}
401401
```
@@ -405,8 +405,7 @@ This program creates ten threads, who all print `Hello, world!`. The
405405
double bars `||`. (The `move` keyword indicates that the closure takes
406406
ownership of any data it uses; we'll have more on the significance of
407407
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.
408+
`spawn`.
410409
411410
One common form of problem in concurrent programs is a 'data race.'
412411
This occurs when two different threads attempt to access the same
@@ -429,7 +428,7 @@ fn main() {
429428
for i in range(0u, 3u) {
430429
Thread::spawn(move || {
431430
for j in range(0, 3) { numbers[j] += 1 }
432-
}).detach();
431+
});
433432
}
434433
}
435434
```
@@ -488,7 +487,7 @@ fn main() {
488487
(*array)[i] += 1;
489488
490489
println!("numbers[{}] is {}", i, (*array)[i]);
491-
}).detach();
490+
});
492491
}
493492
}
494493
```

src/liballoc/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//!
4343
//! Thread::spawn(move || {
4444
//! println!("{}", five);
45-
//! }).detach();
45+
//! });
4646
//! }
4747
//! ```
4848
//!
@@ -63,7 +63,7 @@
6363
//! *number += 1;
6464
//!
6565
//! println!("{}", *number); // prints 6
66-
//! }).detach();
66+
//! });
6767
//! }
6868
//! ```
6969
@@ -106,7 +106,7 @@ use heap::deallocate;
106106
/// let local_numbers = child_numbers.as_slice();
107107
///
108108
/// // Work with the local numbers
109-
/// }).detach();
109+
/// });
110110
/// }
111111
/// }
112112
/// ```

src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ mod tests {
924924
#[test]
925925
fn test_send() {
926926
let n = list_from(&[1i,2,3]);
927-
Thread::spawn(move || {
927+
Thread::scoped(move || {
928928
check_links(&n);
929929
let a: &[_] = &[&1,&2,&3];
930930
assert_eq!(a, n.iter().collect::<Vec<&int>>());

src/libcore/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
//! let spinlock_clone = spinlock.clone();
5151
//! Thread::spawn(move|| {
5252
//! spinlock_clone.store(0, Ordering::SeqCst);
53-
//! }).detach();
53+
//! });
5454
//!
5555
//! // Wait for the other task to release the lock
5656
//! while spinlock.load(Ordering::SeqCst) != 0 {}

src/librustc_driver/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
559559
cfg = cfg.stack_size(STACK_SIZE);
560560
}
561561

562-
match cfg.spawn(move || { std::io::stdio::set_stderr(box w); f() }).join() {
562+
match cfg.scoped(move || { std::io::stdio::set_stderr(box w); f() }).join() {
563563
Ok(()) => { /* fallthrough */ }
564564
Err(value) => {
565565
// Thread panicked without emitting a fatal diagnostic

src/librustc_trans/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ fn run_work_multithreaded(sess: &Session,
928928
}
929929

930930
tx.take().unwrap().send(()).unwrap();
931-
}).detach();
931+
});
932932
}
933933

934934
let mut panicked = false;

src/librustdoc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct Output {
116116

117117
pub fn main() {
118118
static STACK_SIZE: uint = 32000000; // 32MB
119-
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
119+
let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || {
120120
main_args(std::os::args().as_slice())
121121
}).join();
122122
std::os::set_exit_status(res.map_err(|_| ()).unwrap());
@@ -358,7 +358,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
358358
let cr = Path::new(cratefile);
359359
info!("starting to run rustc");
360360

361-
let (mut krate, analysis) = std::thread::Thread::spawn(move |:| {
361+
let (mut krate, analysis) = std::thread::Thread::scoped(move |:| {
362362
let cr = cr;
363363
core::run_core(paths, cfgs, externs, &cr, triple)
364364
}).join().map_err(|_| "rustc failed").unwrap();

src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
157157
None => box io::stderr() as Box<Writer>,
158158
};
159159
io::util::copy(&mut p, &mut err).unwrap();
160-
}).detach();
160+
});
161161
let emitter = diagnostic::EmitterWriter::new(box w2, None);
162162

163163
// Compile the code

src/libstd/io/comm_adapters.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ mod test {
172172
tx.send(vec![3u8, 4u8]).unwrap();
173173
tx.send(vec![5u8, 6u8]).unwrap();
174174
tx.send(vec![7u8, 8u8]).unwrap();
175-
}).detach();
175+
});
176176

177177
let mut reader = ChanReader::new(rx);
178178
let mut buf = [0u8; 3];
@@ -215,7 +215,7 @@ mod test {
215215
tx.send(b"rld\nhow ".to_vec()).unwrap();
216216
tx.send(b"are you?".to_vec()).unwrap();
217217
tx.send(b"".to_vec()).unwrap();
218-
}).detach();
218+
});
219219

220220
let mut reader = ChanReader::new(rx);
221221

@@ -234,7 +234,7 @@ mod test {
234234
writer.write_be_u32(42).unwrap();
235235

236236
let wanted = vec![0u8, 0u8, 0u8, 42u8];
237-
let got = match Thread::spawn(move|| { rx.recv().unwrap() }).join() {
237+
let got = match Thread::scoped(move|| { rx.recv().unwrap() }).join() {
238238
Ok(got) => got,
239239
Err(_) => panic!(),
240240
};

0 commit comments

Comments
 (0)