Skip to content

Commit

Permalink
doc: Update tutorial for task API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Mar 10, 2012
1 parent 91b988e commit 57af1e9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2385,8 +2385,7 @@ The argument to `task::spawn()` is a [unique
closure](#unique-closures) of type `fn~()`, meaning that it takes no
arguments and generates no return value. The effect of `task::spawn()`
is to fire up a child task that will execute the closure in parallel
with the creator. The result is a task id, here stored into the
variable `child_task`.
with the creator.

## Ports and channels

Expand All @@ -2402,10 +2401,10 @@ in parallel. We might write something like:
# fn some_other_expensive_computation() {}
let port = comm::port::<int>();
let chan = comm::chan::<int>(port);
let child_task = task::spawn {||
task::spawn {||
let result = some_expensive_computation();
comm::send(chan, result);
};
}
some_other_expensive_computation();
let result = comm::recv(port);
~~~~
Expand Down Expand Up @@ -2433,10 +2432,10 @@ The next statement actually spawns the child:
# fn some_expensive_computation() -> int { 42 }
# let port = comm::port::<int>();
# let chan = comm::chan::<int>(port);
let child_task = task::spawn {||
task::spawn {||
let result = some_expensive_computation();
comm::send(chan, result);
};
}
~~~~

This child will perform the expensive computation send the result
Expand Down

0 comments on commit 57af1e9

Please sign in to comment.