mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
Manual non-async task removed
This commit is contained in:
@@ -13400,18 +13400,10 @@ Application concepts are easier to reason about.
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
void manual_publishing(std::string* msg)
|
|
||||||
{
|
|
||||||
// Encapsulates thread functionality into the application task
|
|
||||||
std::thread publisher(publish, &msg);
|
|
||||||
publisher.join();
|
|
||||||
}
|
|
||||||
|
|
||||||
void some_fun() {
|
void some_fun() {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
std::thread publisher(publish, &msg); // bad (less expressive and more error-prone)
|
std::thread publisher(publish, &msg); // bad (less expressive and more error-prone)
|
||||||
auto pubtask = std::sync(publish, &msg); // OK
|
auto pubtask = std::async(publish, &msg); // OK
|
||||||
manual_publishing(&msg); // OK (manually crafted task)
|
|
||||||
// ...
|
// ...
|
||||||
publisher.join();
|
publisher.join();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user