Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise std::thread #22435

Merged
merged 2 commits into from
Feb 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::env;
use std::iter::repeat;
use std::str;
use std::string::String;
use std::thread::Thread;
use std::thread;
use std::time::Duration;
use test::MetricMap;

Expand Down Expand Up @@ -447,7 +447,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
loop {
//waiting 1 second for gdbserver start
timer::sleep(Duration::milliseconds(1000));
let result = Thread::scoped(move || {
let result = thread::spawn(move || {
tcp::TcpStream::connect("127.0.0.1:5039").unwrap();
}).join();
if result.is_err() {
Expand Down
16 changes: 8 additions & 8 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
//!
//! ```
//! use std::sync::Arc;
//! use std::thread::Thread;
//! use std::thread;
//!
//! let five = Arc::new(5);
//!
//! for _ in 0..10 {
//! let five = five.clone();
//!
//! Thread::spawn(move || {
//! thread::spawn(move || {
//! println!("{:?}", five);
//! });
//! }
Expand All @@ -52,14 +52,14 @@
//!
//! ```
//! use std::sync::{Arc, Mutex};
//! use std::thread::Thread;
//! use std::thread;
//!
//! let five = Arc::new(Mutex::new(5));
//!
//! for _ in 0..10 {
//! let five = five.clone();
//!
//! Thread::spawn(move || {
//! thread::spawn(move || {
//! let mut number = five.lock().unwrap();
//!
//! *number += 1;
Expand Down Expand Up @@ -95,7 +95,7 @@ use heap::deallocate;
///
/// ```rust
/// use std::sync::Arc;
/// use std::thread::Thread;
/// use std::thread;
///
/// fn main() {
/// let numbers: Vec<_> = (0..100u32).map(|i| i as f32).collect();
Expand All @@ -104,7 +104,7 @@ use heap::deallocate;
/// for _ in 0..10 {
/// let child_numbers = shared_numbers.clone();
///
/// Thread::spawn(move || {
/// thread::spawn(move || {
/// let local_numbers = child_numbers.as_slice();
///
/// // Work with the local numbers
Expand Down Expand Up @@ -621,7 +621,7 @@ mod tests {
use std::option::Option::{Some, None};
use std::sync::atomic;
use std::sync::atomic::Ordering::{Acquire, SeqCst};
use std::thread::Thread;
use std::thread;
use std::vec::Vec;
use super::{Arc, Weak, weak_count, strong_count};
use std::sync::Mutex;
Expand All @@ -648,7 +648,7 @@ mod tests {

let (tx, rx) = channel();

let _t = Thread::spawn(move || {
let _t = thread::spawn(move || {
let arc_v: Arc<Vec<i32>> = rx.recv().unwrap();
assert_eq!((*arc_v)[3], 4);
});
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ mod tests {
use prelude::*;
use std::rand;
use std::hash::{self, SipHasher};
use std::thread::Thread;
use std::thread;
use test::Bencher;
use test;

Expand Down Expand Up @@ -1284,7 +1284,7 @@ mod tests {
#[test]
fn test_send() {
let n = list_from(&[1,2,3]);
Thread::scoped(move || {
thread::spawn(move || {
check_links(&n);
let a: &[_] = &[&1,&2,&3];
assert_eq!(a, n.iter().collect::<Vec<_>>());
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
//! ```
//! use std::sync::Arc;
//! use std::sync::atomic::{AtomicUsize, Ordering};
//! use std::thread::Thread;
//! use std::thread;
//!
//! fn main() {
//! let spinlock = Arc::new(AtomicUsize::new(1));
//!
//! let spinlock_clone = spinlock.clone();
//! Thread::spawn(move|| {
//! thread::spawn(move|| {
//! spinlock_clone.store(0, Ordering::SeqCst);
//! });
//!
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ impl<T> RefCell<T> {
///
/// ```
/// use std::cell::RefCell;
/// use std::thread::Thread;
/// use std::thread;
///
/// let result = Thread::scoped(move || {
/// let result = thread::spawn(move || {
/// let c = RefCell::new(5);
/// let m = c.borrow_mut();
///
Expand Down Expand Up @@ -436,9 +436,9 @@ impl<T> RefCell<T> {
///
/// ```
/// use std::cell::RefCell;
/// use std::thread::Thread;
/// use std::thread;
///
/// let result = Thread::scoped(move || {
/// let result = thread::spawn(move || {
/// let c = RefCell::new(5);
/// let m = c.borrow_mut();
///
Expand Down
6 changes: 3 additions & 3 deletions src/libcoretest/finally.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![allow(deprecated)]

use core::finally::{try_finally, Finally};
use std::thread::Thread;
use std::thread;

#[test]
fn test_success() {
Expand All @@ -22,7 +22,7 @@ fn test_success() {
*i = 10;
},
|i| {
assert!(!Thread::panicking());
assert!(!thread::panicking());
assert_eq!(*i, 10);
*i = 20;
});
Expand All @@ -40,7 +40,7 @@ fn test_fail() {
panic!();
},
|i| {
assert!(Thread::panicking());
assert!(thread::panicking());
assert_eq!(*i, 10);
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
let cr = Path::new(cratefile);
info!("starting to run rustc");

let (mut krate, analysis) = std::thread::Thread::scoped(move || {
let (mut krate, analysis) = std::thread::spawn(move || {
use rustc::session::config::Input;

let cr = cr;
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::old_io::{Command, TempDir};
use std::old_io;
use std::env;
use std::str;
use std::thread::Thread;
use std::thread;
use std::thunk::Thunk;

use std::collections::{HashSet, HashMap};
Expand Down Expand Up @@ -142,7 +142,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
let w1 = old_io::ChanWriter::new(tx);
let w2 = w1.clone();
let old = old_io::stdio::set_stderr(box w1);
Thread::spawn(move || {
thread::spawn(move || {
let mut p = old_io::ChanReader::new(rx);
let mut err = match old {
Some(old) => {
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ macro_rules! try {
/// # Examples
///
/// ```
/// use std::thread::Thread;
/// use std::thread;
/// use std::sync::mpsc;
///
/// // two placeholder functions for now
Expand All @@ -136,8 +136,8 @@ macro_rules! try {
/// let (tx1, rx1) = mpsc::channel();
/// let (tx2, rx2) = mpsc::channel();
///
/// Thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
/// Thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
/// thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
/// thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
///
/// select! (
/// _ = rx1.recv() => println!("the long running task finished first"),
Expand Down
Loading