about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-03-09 16:30:51 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-03-09 17:59:21 +0530
commit894cd3961ab0f63366db40dccaed09f2b7525ead (patch)
tree367d510c786ae8591ac9de2f234343591ad77e82 /src
parent094b6bc8316a9e1aacd8b777fdbe8c9f16448d9f (diff)
parentb426a242e3da27e9a407f9f896bcb86d347f76d1 (diff)
downloadrust-894cd3961ab0f63366db40dccaed09f2b7525ead.tar.gz
rust-894cd3961ab0f63366db40dccaed09f2b7525ead.zip
Rollup merge of #23202 - shepmaster:intro-threads-not-concurrent, r=steveklabnik
 If we end the `scoped` call with a semicolon, the `JoinGuard` will be
dropped and not returned from the `map`. The thread will start up and
we immediately block, making for a very expensive sequential loop.
Diffstat (limited to 'src')
-rw-r--r--src/doc/intro.md26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/doc/intro.md b/src/doc/intro.md
index bb86de64e7a..9e575abeee2 100644
--- a/src/doc/intro.md
+++ b/src/doc/intro.md
@@ -389,11 +389,11 @@ safe concurrent programs.
 Here's an example of a concurrent Rust program:
 
 ```{rust}
-use std::thread::Thread;
+use std::thread;
 
 fn main() {
     let guards: Vec<_> = (0..10).map(|_| {
-        Thread::scoped(|| {
+        thread::scoped(|| {
             println!("Hello, world!");
         })
     }).collect();
@@ -421,16 +421,16 @@ problem.
 Let's see an example. This Rust code will not compile:
 
 ```{rust,ignore}
-use std::thread::Thread;
+use std::thread;
 
 fn main() {
     let mut numbers = vec![1, 2, 3];
 
     let guards: Vec<_> = (0..3).map(|i| {
-        Thread::scoped(move || {
+        thread::scoped(move || {
             numbers[i] += 1;
             println!("numbers[{}] is {}", i, numbers[i]);
-        });
+        })
     }).collect();
 }
 ```
@@ -439,10 +439,10 @@ It gives us this error:
 
 ```text
 7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
-7     Thread::scoped(move || {
+7     thread::scoped(move || {
 8       numbers[i] += 1;
 9       println!("numbers[{}] is {}", i, numbers[i]);
-10     });
+10     })
 error: aborting due to previous error
 ```
 
@@ -471,7 +471,7 @@ mutation doesn't cause a data race.
 Here's what using an Arc with a Mutex looks like:
 
 ```{rust}
-use std::thread::Thread;
+use std::thread;
 use std::sync::{Arc,Mutex};
 
 fn main() {
@@ -479,11 +479,11 @@ fn main() {
 
     let guards: Vec<_> = (0..3).map(|i| {
         let number = numbers.clone();
-        Thread::scoped(move || {
+        thread::scoped(move || {
             let mut array = number.lock().unwrap();
             array[i] += 1;
             println!("numbers[{}] is {}", i, array[i]);
-        });
+        })
     }).collect();
 }
 ```
@@ -535,15 +535,15 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
 safety check that makes this an error about moved values:
 
 ```{rust,ignore}
-use std::thread::Thread;
+use std::thread;
 
 fn main() {
     let numbers = vec![1, 2, 3];
 
     let guards: Vec<_> = (0..3).map(|i| {
-        Thread::scoped(move || {
+        thread::scoped(move || {
             println!("{}", numbers[i]);
-        });
+        })
     }).collect();
 }
 ```