{"id":330263,"date":"2022-03-02T21:00:08","date_gmt":"2022-03-02T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=330263"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=330263","title":{"rendered":"<span>C++20: \u041f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 cppcoro<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a6\/6b0\/3b5\/6a66b03b5067785b902d4d600391254a.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a6\/6b0\/3b5\/6a66b03b5067785b902d4d600391254a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432 \u043c\u043e\u0435\u0439 \u043c\u0438\u043d\u0438-\u0441\u0435\u0440\u0438\u0438 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e <a href=\"https:\/\/github.com\/lewissbaker\/cppcoro\">cppcoro<\/a>. cppcoro \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u043e\u0442 \u041b\u044c\u044e\u0438\u0441\u0430 \u0411\u0435\u0439\u043a\u0435\u0440\u0430 (Lewis Baker). \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (thread pools).<\/p>\n<p>\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ec9\/1bb\/98d\/ec91bb98d4c5aeca4150e4d54b521aeb.png\" width=\"1068\" height=\"383\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ec9\/1bb\/98d\/ec91bb98d4c5aeca4150e4d54b521aeb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e\u043b\u044c\u0437\u044b \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u0432\u0430\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u043e\u0438\u043c\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043f\u043e\u0441\u0442\u0430\u043c\u0438 \u043f\u0440\u043e cppcoro.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/bit.ly\/CoroutinesCppcoro\">C++20: \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 cppcoro<\/a>: \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 cppcoro, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u0440\u0443\u0442\u0438\u043d.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/bit.ly\/CoroutineAbstractions\">C++20: \u041c\u043e\u0449\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 cppcoro<\/a>: \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>cppcoro::sync_wait<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 <code>Awaitable<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f, cppcoro \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>cppcoro::when_all<\/code>.<\/p>\n<h3>when_all<\/h3>\n<ul>\n<li>\n<p><code>when_all<\/code><strong>: <\/strong>\u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>Awaitable<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 <code>Input-Awaitable<\/code><em> <\/em>\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>cpporo::when_all<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443.<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroWhenAll.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;thread>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/task.hpp> #include &lt;cppcoro\/when_all.hpp>  using namespace std::chrono_literals;  cppcoro::task&lt;std::string> getFirst() {     std::this_thread::sleep_for(1s);                       \/\/ (3)     co_return \"First\"; }  cppcoro::task&lt;std::string> getSecond() {      std::this_thread::sleep_for(1s);                      \/\/ (3)     co_return \"Second\"; }  cppcoro::task&lt;std::string> getThird() {      std::this_thread::sleep_for(1s);                     \/\/ (3)     co_return \"Third\"; }   cppcoro::task&lt;> runAll() {                                                           \/\/ (2)     auto[fir, sec, thi] = co_await cppcoro::when_all(getFirst(), getSecond(), getThird());          std::cout &lt;&lt; fir &lt;&lt; \" \" &lt;&lt; sec &lt;&lt; \" \" &lt;&lt; thi &lt;&lt; std::endl;      }  int main() {          std::cout &lt;&lt; std::endl;          auto start = std::chrono::steady_clock::now();          cppcoro::sync_wait(runAll());                          \/\/ (1)          std::cout &lt;&lt; std::endl;          auto end = std::chrono::high_resolution_clock::now();     std::chrono::duration&lt;double> elapsed = end - start;   \/\/ (4)     std::cout &lt;&lt; \"Execution time \" &lt;&lt; elapsed.count() &lt;&lt; \" seconds.\" &lt;&lt; std::endl;          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f <code>cppcoro::sync_wait(runAll())<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 1) \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <code>Awaitable runAll<\/code>. <code>runAll<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <code>Awaitable getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 2). <code>Awaitable runAll<\/code>, <code>getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u0440\u0430\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>get<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 (\u0441\u0442\u0440\u043e\u043a\u0430 3). \u0422\u0440\u0438 \u0440\u0430\u0437\u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u042d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432 <code>cppcoro::sync_wait(runAll())<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u0421\u0442\u0440\u043e\u043a\u0430 4 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/38b\/11d\/b7f\/38b11db7faa94b6a9476c7c6a2ff35e6.png\" width=\"454\" height=\"256\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/38b\/11d\/b7f\/38b11db7faa94b6a9476c7c6a2ff35e6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>cppcoro::when_all<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043d\u0435\u0439 \u043f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<h3>static_thread_pool<\/h3>\n<ul>\n<li>\n<p><code>static_thead_pool<\/code>: \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p><code>cppcoro::static_thread_pool<\/code> \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437. \u042d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u043a\u0430\u0436\u0435\u0442\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f C++11 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/thread\/thread\/hardware_concurrency\">std::thread::hardware_concurrency()<\/a>. <code>std::thread::hardware_concurrency<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0438\u043b\u0438 \u044f\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0432\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044f \u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u2014 \u043e\u043d \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b <code>getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> .<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroWhenAllOnThreadPool.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;thread>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/task.hpp> #include &lt;cppcoro\/static_thread_pool.hpp> #include &lt;cppcoro\/when_all.hpp>   using namespace std::chrono_literals;  cppcoro::task&lt;std::string> getFirst() {     std::this_thread::sleep_for(1s);     co_return \"First\"; }  cppcoro::task&lt;std::string> getSecond() {     std::this_thread::sleep_for(1s);     co_return \"Second\"; }  cppcoro::task&lt;std::string> getThird() {     std::this_thread::sleep_for(1s);     co_return \"Third\"; }  template &lt;typename Func> cppcoro::task&lt;std::string> runOnThreadPool(cppcoro::static_thread_pool&amp; tp, Func func) {     co_await tp.schedule();     auto res = co_await func();     co_return res; }  cppcoro::task&lt;> runAll(cppcoro::static_thread_pool&amp; tp) {          auto[fir, sec, thi] = co_await cppcoro::when_all(    \/\/ (3)         runOnThreadPool(tp, getFirst),         runOnThreadPool(tp, getSecond),          runOnThreadPool(tp, getThird));          std::cout &lt;&lt; fir &lt;&lt; \" \" &lt;&lt; sec &lt;&lt; \" \" &lt;&lt; thi &lt;&lt; std::endl;      }      int main() {          std::cout &lt;&lt; std::endl;          auto start = std::chrono::steady_clock::now();      cppcoro::static_thread_pool tp;                         \/\/ (1)     cppcoro::sync_wait(runAll(tp));                         \/\/ (2)          std::cout &lt;&lt; std::endl;          auto end = std::chrono::high_resolution_clock::now();     std::chrono::duration&lt;double> elapsed = end - start;    \/\/ (4)     std::cout &lt;&lt; \"Execution time \" &lt;&lt; elapsed.count() &lt;&lt; \" seconds.\" &lt;&lt; std::endl;          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <code>cppcoroWhenAll.cpp<\/code>. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 (1) \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 <code>tp<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>runAll(tp)<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 2). \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>runAll<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430\u043c (\u0441\u0442\u0440\u043e\u043a\u0430 3) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f main \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043e\u0434\u043d\u0443, \u0430 \u043d\u0435 \u0437\u0430 \u0442\u0440\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6e8\/73d\/257\/6e873d257266434a0a3651b94c33c612.png\" width=\"544\" height=\"256\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6e8\/73d\/257\/6e873d257266434a0a3651b94c33c612.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u0437\u0430\u0449\u0435\u043b\u043a\u0430\u043c\u0438 \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u0430\u043c\u0438 C++20. \u0417\u0430\u0449\u0435\u043b\u043a\u0438 (latches) \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u044b (barrier) \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e. <code>cppcoro<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0449\u0435\u043b\u043a\u0438 \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u044b.<\/p>\n<h3>async_latch<\/h3>\n<ul>\n<li>\n<p><code>async_latch<\/code>: \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <code>cppcoroLatch.cpp<\/code> \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>cppcoro::async_latch<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroLatch.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;future>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/async_latch.hpp> #include &lt;cppcoro\/task.hpp>  using namespace std::chrono_literals;   cppcoro::task&lt;> waitFor(cppcoro::async_latch&amp; latch) {     std::cout &lt;&lt; \"Before co_await\" &lt;&lt; std::endl;     co_await latch;                              \/\/ (3)     std::cout &lt;&lt; \"After co_await\" &lt;&lt; std::endl; }  int main() {          std::cout &lt;&lt; std::endl;      cppcoro::async_latch latch(3);              \/\/ (1)                                                  \/\/ (2)     auto waiter = std::async([&amp;latch]{ cppcoro::sync_wait(waitFor(latch)); });       auto counter1 = std::async([&amp;latch] {       \/\/ (2)         std::this_thread::sleep_for(2s);         std::cout &lt;&lt; \"counter1: latch.count_down() \" &lt;&lt; std::endl;         latch.count_down();     });              auto counter2 = std::async([&amp;latch] {      \/\/ (2)         std::this_thread::sleep_for(1s);         std::cout &lt;&lt; \"counter2: latch.count_down(2) \" &lt;&lt; std::endl;         latch.count_down(2);     });      waiter.get(), counter1.get(), counter2.get();          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u043e\u043a\u0435 (1) \u044f \u0441\u043e\u0437\u0434\u0430\u044e <code>cppcoro::asynch_latch<\/code> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u0430\u0432\u043d\u044b\u043c 3. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>std::async<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 (2)) \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0440\u0435\u0445 \u043a\u043e\u0440\u0443\u0442\u0438\u043d. \u041a\u0430\u0436\u0434\u044b\u0439 <code>std::async<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>latch<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 (3) \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 <code>waitFor<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 <code>counter1<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 1 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, <code>counter2<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u0435\u0442 2 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b47\/5d9\/370\/b475d937023cf4773cb31ce8591e5a66.png\" width=\"485\" height=\"270\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b47\/5d9\/370\/b475d937023cf4773cb31ce8591e5a66.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0443\u0441\u043f\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e \u0442\u0440\u0435\u0445 \u0438\u0437 <a href=\"https:\/\/www.modernescpp.com\/index.php\/thebigfour\">\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u043a\u0438 C++20<\/a>: \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430\u0445, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u0445 \u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430\u0445. \u0412 \u043c\u043e\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u043a\u0435 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043e\u0434\u0443\u043b\u0438. \u041e\u043d\u0438 \u0438 \u0441\u0442\u0430\u043d\u0443\u0442 \u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0438\u0445 <a href=\"https:\/\/www.modernescpp.com\/index.php\/cpp20-modules\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432.<\/a><\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 C++20, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0442\u043e\u0436\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0441\u0432\u044f\u0436\u0438\u0442\u0435\u0441\u044c \u0441\u043e \u043c\u043d\u043e\u0439. \u042f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0435\u0435 \u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439\/\u043d\u0435\u043c\u0435\u0446\u043a\u0438\u0439 \u044f\u0437\u044b\u043a, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<h4>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0441\u0442\u0430\u0432\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430<\/h4>\n<p>\u041c\u043e\u044f \u043d\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0441\u0442\u0430\u0432\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 &#171;Fundamentals for C++ Professionals&#187; \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0432 \u0430\u043f\u0440\u0435\u043b\u0435. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/bit.ly\/MentoringProgramModernesCpp\">\u0437\u0434\u0435\u0441\u044c.<\/a><\/p>\n<hr\/>\n<p>\u0412\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043d\u0430 <a href=\"https:\/\/otus.pw\/2cvY\/\">\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a<\/a> \u0432 OTUS \u00ab\u0423\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438\u00bb, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b. \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043e\u0431\u0437\u043e\u0440 \u0443\u043c\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 stl, unique_ptr, Shared_ptr, weak_ptr.  <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/654159\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/654159\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432 \u043c\u043e\u0435\u0439 \u043c\u0438\u043d\u0438-\u0441\u0435\u0440\u0438\u0438 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e <a href=\"https:\/\/github.com\/lewissbaker\/cppcoro\">cppcoro<\/a>. cppcoro \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u043e\u0442 \u041b\u044c\u044e\u0438\u0441\u0430 \u0411\u0435\u0439\u043a\u0435\u0440\u0430 (Lewis Baker). \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (thread pools).<\/p>\n<p>\u00a0<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043f\u043e\u043b\u044c\u0437\u044b \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u0432\u0430\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0431\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u043e\u0438\u043c\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u043f\u043e\u0441\u0442\u0430\u043c\u0438 \u043f\u0440\u043e cppcoro.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/bit.ly\/CoroutinesCppcoro\">C++20: \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 cppcoro<\/a>: \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 cppcoro, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043a\u043e\u0440\u0443\u0442\u0438\u043d.<\/p>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p><a href=\"https:\/\/bit.ly\/CoroutineAbstractions\">C++20: \u041c\u043e\u0449\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 cppcoro<\/a>: \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>cppcoro::sync_wait<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 <code>Awaitable<\/code> \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f, cppcoro \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>cppcoro::when_all<\/code>.<\/p>\n<h3>when_all<\/h3>\n<ul>\n<li>\n<p><code>when_all<\/code><strong>: <\/strong>\u0441\u043e\u0437\u0434\u0430\u0435\u0442 <code>Awaitable<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0432\u043e\u0438 <code>Input-Awaitable<\/code><em> <\/em>\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u042f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>cpporo::when_all<\/code> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443.<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroWhenAll.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;thread>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/task.hpp> #include &lt;cppcoro\/when_all.hpp>  using namespace std::chrono_literals;  cppcoro::task&lt;std::string> getFirst() {     std::this_thread::sleep_for(1s);                       \/\/ (3)     co_return \"First\"; }  cppcoro::task&lt;std::string> getSecond() {      std::this_thread::sleep_for(1s);                      \/\/ (3)     co_return \"Second\"; }  cppcoro::task&lt;std::string> getThird() {      std::this_thread::sleep_for(1s);                     \/\/ (3)     co_return \"Third\"; }   cppcoro::task&lt;> runAll() {                                                           \/\/ (2)     auto[fir, sec, thi] = co_await cppcoro::when_all(getFirst(), getSecond(), getThird());          std::cout &lt;&lt; fir &lt;&lt; \" \" &lt;&lt; sec &lt;&lt; \" \" &lt;&lt; thi &lt;&lt; std::endl;      }  int main() {          std::cout &lt;&lt; std::endl;          auto start = std::chrono::steady_clock::now();          cppcoro::sync_wait(runAll());                          \/\/ (1)          std::cout &lt;&lt; std::endl;          auto end = std::chrono::high_resolution_clock::now();     std::chrono::duration&lt;double> elapsed = end - start;   \/\/ (4)     std::cout &lt;&lt; \"Execution time \" &lt;&lt; elapsed.count() &lt;&lt; \" seconds.\" &lt;&lt; std::endl;          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f <code>cppcoro::sync_wait(runAll())<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 1) \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <code>Awaitable runAll<\/code>. <code>runAll<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <code>Awaitable getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 2). <code>Awaitable runAll<\/code>, <code>getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u0440\u0443\u0442\u0438\u0440\u0430\u043c\u0438. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>get<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 (\u0441\u0442\u0440\u043e\u043a\u0430 3). \u0422\u0440\u0438 \u0440\u0430\u0437\u0430 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u042d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432 <code>cppcoro::sync_wait(runAll())<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b. \u0421\u0442\u0440\u043e\u043a\u0430 4 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>cppcoro::when_all<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043d\u0435\u0439 \u043f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<h3>static_thread_pool<\/h3>\n<ul>\n<li>\n<p><code>static_thead_pool<\/code>: \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u043f\u0443\u043b\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p><code>cppcoro::static_thread_pool<\/code> \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0438\u043b\u0438 \u0431\u0435\u0437. \u042d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u043a\u0430\u0436\u0435\u0442\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f C++11 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/thread\/thread\/hardware_concurrency\">std::thread::hardware_concurrency()<\/a>. <code>std::thread::hardware_concurrency<\/code> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0438\u043b\u0438 \u044f\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0432\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u044f \u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u2014 \u043e\u043d \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b <code>getFirst<\/code>, <code>getSecond<\/code> \u0438 <code>getThird<\/code> .<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroWhenAllOnThreadPool.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;thread>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/task.hpp> #include &lt;cppcoro\/static_thread_pool.hpp> #include &lt;cppcoro\/when_all.hpp>   using namespace std::chrono_literals;  cppcoro::task&lt;std::string> getFirst() {     std::this_thread::sleep_for(1s);     co_return \"First\"; }  cppcoro::task&lt;std::string> getSecond() {     std::this_thread::sleep_for(1s);     co_return \"Second\"; }  cppcoro::task&lt;std::string> getThird() {     std::this_thread::sleep_for(1s);     co_return \"Third\"; }  template &lt;typename Func> cppcoro::task&lt;std::string> runOnThreadPool(cppcoro::static_thread_pool&amp; tp, Func func) {     co_await tp.schedule();     auto res = co_await func();     co_return res; }  cppcoro::task&lt;> runAll(cppcoro::static_thread_pool&amp; tp) {          auto[fir, sec, thi] = co_await cppcoro::when_all(    \/\/ (3)         runOnThreadPool(tp, getFirst),         runOnThreadPool(tp, getSecond),          runOnThreadPool(tp, getThird));          std::cout &lt;&lt; fir &lt;&lt; \" \" &lt;&lt; sec &lt;&lt; \" \" &lt;&lt; thi &lt;&lt; std::endl;      }      int main() {          std::cout &lt;&lt; std::endl;          auto start = std::chrono::steady_clock::now();      cppcoro::static_thread_pool tp;                         \/\/ (1)     cppcoro::sync_wait(runAll(tp));                         \/\/ (2)          std::cout &lt;&lt; std::endl;          auto end = std::chrono::high_resolution_clock::now();     std::chrono::duration&lt;double> elapsed = end - start;    \/\/ (4)     std::cout &lt;&lt; \"Execution time \" &lt;&lt; elapsed.count() &lt;&lt; \" seconds.\" &lt;&lt; std::endl;          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <code>cppcoroWhenAll.cpp<\/code>. \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 (1) \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 <code>tp<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>runAll(tp)<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 2). \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>runAll<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0443\u043b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430\u043c (\u0441\u0442\u0440\u043e\u043a\u0430 3) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f main \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430 \u043e\u0434\u043d\u0443, \u0430 \u043d\u0435 \u0437\u0430 \u0442\u0440\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441 \u0437\u0430\u0449\u0435\u043b\u043a\u0430\u043c\u0438 \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u0430\u043c\u0438 C++20. \u0417\u0430\u0449\u0435\u043b\u043a\u0438 (latches) \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u044b (barrier) \u2014 \u044d\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e. <code>cppcoro<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0437\u0430\u0449\u0435\u043b\u043a\u0438 \u0438 \u0431\u0430\u0440\u044c\u0435\u0440\u044b.<\/p>\n<h3>async_latch<\/h3>\n<ul>\n<li>\n<p><code>async_latch<\/code>: \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <code>cppcoroLatch.cpp<\/code> \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>cppcoro::async_latch<\/code>.<\/p>\n<pre><code class=\"cpp\">\/\/ cppcoroLatch.cpp  #include &lt;chrono> #include &lt;iostream> #include &lt;future>  #include &lt;cppcoro\/sync_wait.hpp> #include &lt;cppcoro\/async_latch.hpp> #include &lt;cppcoro\/task.hpp>  using namespace std::chrono_literals;   cppcoro::task&lt;> waitFor(cppcoro::async_latch&amp; latch) {     std::cout &lt;&lt; \"Before co_await\" &lt;&lt; std::endl;     co_await latch;                              \/\/ (3)     std::cout &lt;&lt; \"After co_await\" &lt;&lt; std::endl; }  int main() {          std::cout &lt;&lt; std::endl;      cppcoro::async_latch latch(3);              \/\/ (1)                                                  \/\/ (2)     auto waiter = std::async([&amp;latch]{ cppcoro::sync_wait(waitFor(latch)); });       auto counter1 = std::async([&amp;latch] {       \/\/ (2)         std::this_thread::sleep_for(2s);         std::cout &lt;&lt; \"counter1: latch.count_down() \" &lt;&lt; std::endl;         latch.count_down();     });              auto counter2 = std::async([&amp;latch] {      \/\/ (2)         std::this_thread::sleep_for(1s);         std::cout &lt;&lt; \"counter2: latch.count_down(2) \" &lt;&lt; std::endl;         latch.count_down(2);     });      waiter.get(), counter1.get(), counter2.get();          std::cout &lt;&lt; std::endl;  }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u043e\u043a\u0435 (1) \u044f \u0441\u043e\u0437\u0434\u0430\u044e <code>cppcoro::asynch_latch<\/code> \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0440\u0430\u0432\u043d\u044b\u043c 3. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>std::async<\/code> (\u0441\u0442\u0440\u043e\u043a\u0430 (2)) \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0440\u0435\u0445 \u043a\u043e\u0440\u0443\u0442\u0438\u043d. \u041a\u0430\u0436\u0434\u044b\u0439 <code>std::async<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>latch<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 (3) \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 <code>waitFor<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u044b\u043c \u043d\u0443\u043b\u044e. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u0430 <code>counter1<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 1 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, <code>counter2<\/code> \u0437\u0430\u0441\u044b\u043f\u0430\u0435\u0442 \u043d\u0430 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0438 \u043e\u0442\u0441\u0447\u0438\u0442\u0430\u0435\u0442 2 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0443\u0441\u043f\u0435\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e \u0442\u0440\u0435\u0445 \u0438\u0437 <a href=\"https:\/\/www.modernescpp.com\/index.php\/thebigfour\">\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u043a\u0438 C++20<\/a>: \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0430\u0445, \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u0445 \u0438 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0430\u0445. \u0412 \u043c\u043e\u0435\u043c \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0438 \u043f\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u043a\u0435 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043e\u0434\u0443\u043b\u0438. \u041e\u043d\u0438 \u0438 \u0441\u0442\u0430\u043d\u0443\u0442 \u0442\u0435\u043c\u043e\u0439 \u043c\u043e\u0438\u0445 <a href=\"https:\/\/www.modernescpp.com\/index.php\/cpp20-modules\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432.<\/a><\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u0442 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 C++20, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0442\u043e\u0436\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0441\u0432\u044f\u0436\u0438\u0442\u0435\u0441\u044c \u0441\u043e \u043c\u043d\u043e\u0439. \u042f \u0441 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0435\u0435 \u0438 \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0443 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439\/\u043d\u0435\u043c\u0435\u0446\u043a\u0438\u0439 \u044f\u0437\u044b\u043a, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<h4>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0441\u0442\u0430\u0432\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430<\/h4>\n<p>\u041c\u043e\u044f \u043d\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0441\u0442\u0430\u0432\u043d\u0438\u0447\u0435\u0441\u0442\u0432\u0430 &#171;Fundamentals for C++ Professionals&#187; \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0432 \u0430\u043f\u0440\u0435\u043b\u0435. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/bit.ly\/MentoringProgramModernesCpp\">\u0437\u0434\u0435\u0441\u044c.<\/a><\/p>\n<hr\/>\n<p>\u0412\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u043d\u0430 <a href=\"https:\/\/otus.pw\/2cvY\/\">\u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0443\u0440\u043e\u043a<\/a> \u0432 OTUS \u00ab\u0423\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438\u00bb, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b. \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043e\u0431\u0437\u043e\u0440 \u0443\u043c\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 stl, unique_ptr, Shared_ptr, weak_ptr.  <\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/654159\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/654159\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-330263","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=330263"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330263\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=330263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=330263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=330263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}