提交 3b399afa 编写于 作者: B Brian Anderson

Merge pull request #2847 from ben0x539/incoming

Tiny documentation fixes in rust.md and src/libcore/task.rs
...@@ -2871,12 +2871,12 @@ Consists of 2 statements, 3 expressions and 12 points: ...@@ -2871,12 +2871,12 @@ Consists of 2 statements, 3 expressions and 12 points:
* the point after evaluating the static initializer `"hello, world"` * the point after evaluating the static initializer `"hello, world"`
* the point after the first statement * the point after the first statement
* the point before the second statement * the point before the second statement
* the point before evaluating the function value `print` * the point before evaluating the function value `println`
* the point after evaluating the function value `print` * the point after evaluating the function value `println`
* the point before evaluating the arguments to `print` * the point before evaluating the arguments to `println`
* the point before evaluating the symbol `s` * the point before evaluating the symbol `s`
* the point after evaluating the symbol `s` * the point after evaluating the symbol `s`
* the point after evaluating the arguments to `print` * the point after evaluating the arguments to `println`
* the point after the second statement * the point after the second statement
...@@ -2894,9 +2894,9 @@ Consists of 1 statement, 7 expressions and 14 points: ...@@ -2894,9 +2894,9 @@ Consists of 1 statement, 7 expressions and 14 points:
* the point before the statement * the point before the statement
* the point before evaluating the function value `print` * the point before evaluating the function value `println`
* the point after evaluating the function value `print` * the point after evaluating the function value `println`
* the point before evaluating the arguments to `print` * the point before evaluating the arguments to `println`
* the point before evaluating the arguments to `+` * the point before evaluating the arguments to `+`
* the point before evaluating the function value `x` * the point before evaluating the function value `x`
* the point after evaluating the function value `x` * the point after evaluating the function value `x`
...@@ -2907,7 +2907,7 @@ Consists of 1 statement, 7 expressions and 14 points: ...@@ -2907,7 +2907,7 @@ Consists of 1 statement, 7 expressions and 14 points:
* the point before evaluating the arguments to `y` * the point before evaluating the arguments to `y`
* the point after evaluating the arguments to `y` * the point after evaluating the arguments to `y`
* the point after evaluating the arguments to `+` * the point after evaluating the arguments to `+`
* the point after evaluating the arguments to `print` * the point after evaluating the arguments to `println`
The typestate system reasons over points, rather than statements or The typestate system reasons over points, rather than statements or
...@@ -3186,7 +3186,7 @@ let x: ~int = ~10; ...@@ -3186,7 +3186,7 @@ let x: ~int = ~10;
~~~~~~~~ ~~~~~~~~
Some operations (such as field selection) implicitly dereference boxes. An Some operations (such as field selection) implicitly dereference boxes. An
example of an @dfn{implicit dereference} operation performed on box values: example of an _implicit dereference_ operation performed on box values:
~~~~~~~~ ~~~~~~~~
let x = @{y: 10}; let x = @{y: 10};
...@@ -3196,8 +3196,8 @@ assert x.y == 10; ...@@ -3196,8 +3196,8 @@ assert x.y == 10;
Other operations act on box values as single-word-sized address values. For Other operations act on box values as single-word-sized address values. For
these operations, to access the value held in the box requires an explicit these operations, to access the value held in the box requires an explicit
dereference of the box value. Explicitly dereferencing a box is indicated with dereference of the box value. Explicitly dereferencing a box is indicated with
the unary *star* operator `*`. Examples of such @dfn{explicit the unary *star* operator `*`. Examples of such _explicit dereference_
dereference} operations are: operations are:
* copying box values (`x = y`) * copying box values (`x = y`)
* passing box values to functions (`f(x,y)`) * passing box values to functions (`f(x,y)`)
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
* let po = comm::port(); * let po = comm::port();
* let ch = comm::chan(po); * let ch = comm::chan(po);
* *
* task::spawn {|| * do task::spawn {
* comm::send(ch, "Hello, World"); * comm::send(ch, "Hello, World");
* }); * }
* *
* io::println(comm::recv(p)); * io::println(comm::recv(p));
* ~~~ * ~~~
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* # Example * # Example
* *
* ~~~ * ~~~
* spawn {|| * do spawn {
* log(error, "Hello, World!"); * log(error, "Hello, World!");
* } * }
* ~~~ * ~~~
...@@ -350,7 +350,6 @@ fn run_with<A:send>(-builder: builder, ...@@ -350,7 +350,6 @@ fn run_with<A:send>(-builder: builder,
+f: fn~(+A)) { +f: fn~(+A)) {
/*! /*!
*
* Runs a task, while transfering ownership of one argument to the * Runs a task, while transfering ownership of one argument to the
* child. * child.
* *
...@@ -412,15 +411,13 @@ fn spawn(+f: fn~()) { ...@@ -412,15 +411,13 @@ fn spawn(+f: fn~()) {
fn spawn_with<A:send>(+arg: A, +f: fn~(+A)) { fn spawn_with<A:send>(+arg: A, +f: fn~(+A)) {
/*! /*!
* Runs a new task while providing a channel from the parent to the child * Runs a task, while transfering ownership of one argument to the
* child.
* *
* Sets up a communication channel from the current task to the new * This is useful for transfering ownership of noncopyables to
* child task, passes the port to child's body, and returns a channel * another task.
* linked to the port to the parent.
* *
* This encapsulates some boilerplate handshaking logic that would * This function is equivalent to `run_with(builder(), arg, f)`.
* otherwise be required to establish communication from the parent
* to the child.
*/ */
run_with(builder(), arg, f) run_with(builder(), arg, f)
...@@ -443,7 +440,7 @@ fn spawn_listener<A:send>(+f: fn~(comm::port<A>)) -> comm::chan<A> { ...@@ -443,7 +440,7 @@ fn spawn_listener<A:send>(+f: fn~(comm::port<A>)) -> comm::chan<A> {
* *
* let po = comm::port(); * let po = comm::port();
* let ch = comm::chan(po); * let ch = comm::chan(po);
* let ch = spawn_listener {|po| * let ch = do spawn_listener |po| {
* // Now the child has a port called 'po' to read from and * // Now the child has a port called 'po' to read from and
* // an environment-captured channel called 'ch'. * // an environment-captured channel called 'ch'.
* }; * };
...@@ -537,13 +534,15 @@ fn get_task() -> task { ...@@ -537,13 +534,15 @@ fn get_task() -> task {
* *
* # Example * # Example
* *
* task::unkillable {|| * ~~~
* // detach / yield / destroy must all be called together * do task::unkillable {
* rustrt::rust_port_detach(po); * // detach / yield / destroy must all be called together
* // This must not result in the current task being killed * rustrt::rust_port_detach(po);
* task::yield(); * // This must not result in the current task being killed
* rustrt::rust_port_destroy(po); * task::yield();
* } * rustrt::rust_port_destroy(po);
* }
* ~~~
*/ */
unsafe fn unkillable(f: fn()) { unsafe fn unkillable(f: fn()) {
class allow_failure { class allow_failure {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册