mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #1059 from luav/example-cp.4
Example CP.4 (task vs thread)
This commit is contained in:
commit
0a85bd8382
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user