about summary refs log tree commit diff
path: root/src/doc/guide-tasks.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/guide-tasks.md')
-rw-r--r--src/doc/guide-tasks.md30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md
index 957b1d6ccc6..81d7f37d6fb 100644
--- a/src/doc/guide-tasks.md
+++ b/src/doc/guide-tasks.md
@@ -269,7 +269,7 @@ later.
 The basic example below illustrates this.
 
 ~~~
-extern crate sync;
+use std::sync::Future;
 
 # fn main() {
 # fn make_a_sandwich() {};
@@ -278,7 +278,7 @@ fn fib(n: u64) -> u64 {
     12586269025
 }
 
-let mut delayed_fib = sync::Future::spawn(proc() fib(50));
+let mut delayed_fib = Future::spawn(proc() fib(50));
 make_a_sandwich();
 println!("fib(50) = {}", delayed_fib.get())
 # }
@@ -294,7 +294,7 @@ Here is another example showing how futures allow you to background computations
 be distributed on the available cores.
 
 ~~~
-# extern crate sync;
+# use std::sync::Future;
 fn partial_sum(start: uint) -> f64 {
     let mut local_sum = 0f64;
     for num in range(start*100000, (start+1)*100000) {
@@ -304,7 +304,7 @@ fn partial_sum(start: uint) -> f64 {
 }
 
 fn main() {
-    let mut futures = Vec::from_fn(1000, |ind| sync::Future::spawn( proc() { partial_sum(ind) }));
+    let mut futures = Vec::from_fn(1000, |ind| Future::spawn( proc() { partial_sum(ind) }));
 
     let mut final_res = 0f64;
     for ft in futures.mut_iter()  {
@@ -329,10 +329,8 @@ Here is a small example showing how to use Arcs. We wish to run concurrently sev
 a single large vector of floats. Each task needs the full vector to perform its duty.
 
 ~~~
-extern crate sync;
-
-use sync::Arc;
 use std::rand;
+use std::sync::Arc;
 
 fn pnorm(nums: &[f64], p: uint) -> f64 {
     nums.iter().fold(0.0, |a, b| a + b.powf(p as f64)).powf(1.0 / (p as f64))
@@ -357,9 +355,8 @@ at the power given as argument and takes the inverse power of this value). The A
 created by the line
 
 ~~~
-# extern crate sync;
 # use std::rand;
-# use sync::Arc;
+# use std::sync::Arc;
 # fn main() {
 # let numbers = Vec::from_fn(1000000, |_| rand::random::<f64>());
 let numbers_arc=Arc::new(numbers);
@@ -371,9 +368,8 @@ it's contents. Within the task's procedure, the captured Arc reference can be us
 reference to the underlying vector as if it were local.
 
 ~~~
-# extern crate sync;
 # use std::rand;
-# use sync::Arc;
+# use std::sync::Arc;
 # fn pnorm(nums: &[f64], p: uint) -> f64 { 4.0 }
 # fn main() {
 # let numbers=Vec::from_fn(1000000, |_| rand::random::<f64>());
@@ -461,9 +457,9 @@ the string in response.  The child terminates when it receives `0`.
 Here is the function that implements the child task:
 
 ~~~
-extern crate sync;
+use std::comm::DuplexStream;
 # fn main() {
-fn stringifier(channel: &sync::DuplexStream<String, uint>) {
+fn stringifier(channel: &DuplexStream<String, uint>) {
     let mut value: uint;
     loop {
         value = channel.recv();
@@ -485,10 +481,10 @@ response itself is simply the stringified version of the received value,
 Here is the code for the parent task:
 
 ~~~
-extern crate sync;
+use std::comm::duplex;
 # use std::task::spawn;
-# use sync::DuplexStream;
-# fn stringifier(channel: &sync::DuplexStream<String, uint>) {
+# use std::comm::DuplexStream;
+# fn stringifier(channel: &DuplexStream<String, uint>) {
 #     let mut value: uint;
 #     loop {
 #         value = channel.recv();
@@ -498,7 +494,7 @@ extern crate sync;
 # }
 # fn main() {
 
-let (from_child, to_child) = sync::duplex();
+let (from_child, to_child) = duplex();
 
 spawn(proc() {
     stringifier(&to_child);