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

Sync docs and comments with code in hello_world example #1328

Merged
merged 1 commit into from Dec 8, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/tutorial/examples.qbk
Expand Up @@ -257,9 +257,9 @@ beginning with `main()`:

In this excerpt of the code we again see the use of futures. This time
the futures are stored in a vector so that they can easily be accessed.
[funcref hpx::lcos::wait]`()` is a family of functions that wait on for an `std::vector<>`
[funcref hpx::lcos::wait_all]`()` is a family of functions that wait on for an `std::vector<>`
of futures to become ready. In this piece of code, we are using the synchronous
version of [funcref hpx::lcos::wait]`()`, which takes one argument (the `std::vector<>` of
version of [funcref hpx::lcos::wait_all]`()`, which takes one argument (the `std::vector<>` of
futures to wait on). This function will not return until all the futures in the
vector have been executed.

Expand All @@ -283,19 +283,19 @@ the action above:
[hello_world_foreman]

Now, before we discuss `hello_world_foreman()`, let's talk about the
[funcref hpx::lcos::wait]`()` function. [funcref hpx::lcos::wait]`()` provides a way to make sure
[funcref hpx::lcos::wait_each]`()` function. [funcref hpx::lcos::wait_each]`()` provides a way to make sure
that all of the futures have finished being calculated without having to call
[memberref hpx::lcos::future::get]`()` for each one. The version of [funcref hpx::lcos::wait]`()` used here performs an
[memberref hpx::lcos::future::get]`()` for each one. The version of [funcref hpx::lcos::wait_each]`()` used here performs a
non-blocking wait, which acts on an `std::vector<>`. It queries the state of
the futures, waiting for them to finish. Whenever a future becomes marked as
ready, [funcref hpx::lcos::wait]`()` invokes a callback function provided by the user,
ready, [funcref hpx::lcos::wait_each]`()` invokes a callback function provided by the user,
supplying the callback function with the index of the future in the
`std::vector<>` and the result of the future.

In `hello_world_foreman()`, an `std::set<>` called `attendance` keeps track of
which OS-threads have printed out the hello world message. When the OS-thread
prints out the statement, the future is marked as ready, and
[funcref hpx::lcos::wait]`()` invokes the callback function, in this case a C+11 lambda.
[funcref hpx::lcos::wait_each]`()` invokes the callback function, in this case a C++11 lambda.
This lambda erases the OS-threads id from the set `attendance`, thus letting
`hello_world_foreman()` know which OS-threads still need to print out hello
world. However, if the future returns a value of -1, the future executed on an
Expand All @@ -306,7 +306,7 @@ the OS-thread id in `attendance`.
Finally, let us look at `hello_world_worker()`. Here, `hello_world_worker()`
checks to see if it is on the target OS-thread. If it is executing on the
correct OS-thread, it prints out the hello world message and returns the
OS-thread id to [funcref hpx::lcos::wait]`()` in `hello_world_foreman()`. If it is
OS-thread id to [funcref hpx::lcos::wait_each]`()` in `hello_world_foreman()`. If it is
not executing on the correct OS-thread, it returns a value of -1, which causes
`hello_world_foreman()` to leave the OS-thread id in `attendance`.

Expand Down
8 changes: 4 additions & 4 deletions examples/quickstart/hello_world.cpp
Expand Up @@ -102,10 +102,10 @@ void hello_world_foreman()
}

// Wait for all of the futures to finish. The callback version of the
// hpx::lcos::wait function takes two arguments: a vector of futures,
// hpx::lcos::wait_each function takes two arguments: a vector of futures,
// and a binary callback. The callback takes two arguments; the first
// is the index of the future in the vector, and the second is the
// return value of the future. hpx::lcos::wait doesn't return until
// return value of the future. hpx::lcos::wait_each doesn't return until
// all the futures in the vector have returned.
hpx::lcos::local::spinlock mtx;
hpx::lcos::wait_each(futures,
Expand Down Expand Up @@ -149,8 +149,8 @@ int main()
futures.push_back(hpx::async<action_type>(node));
}

// The non-callback version of hpx::lcos::wait takes a single parameter,
// a future of vectors to wait on. hpx::wait_all only returns when
// The non-callback version of hpx::lcos::wait_all takes a single parameter,
// a vector of futures to wait on. hpx::wait_all only returns when
// all of the futures have finished.
hpx::wait_all(futures);
return 0;
Expand Down