Merge pull request #1059 from luav/example-cp.4

Example CP.4 (task vs thread)
This commit is contained in:
Andrew Pardoe 2017-10-23 11:25:56 -07:00 committed by GitHub
commit 0a85bd8382

View File

@ -13393,7 +13393,13 @@ Application concepts are easier to reason about.
##### Example
???
void some_fun() {
std::string msg, msg2;
std::thread publisher([&] { msg = "Hello"; }); // bad (less expressive and more error-prone)
auto pubtask = std::async([&] { msg2 = "Hello"; }); // OK
// ...
publisher.join();
}
##### Note