{"id":157735,"date":"2012-11-12T18:26:08","date_gmt":"2012-11-12T14:26:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=157735"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=157735","title":{"rendered":"<span class=\"post_title\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u2013 \u0431\u043b\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u00ab\u0441\u0438\u0433\u043d\u0430\u043b\u044b\u00bb \u0438 \u0442.\u0434. \u041b\u043e\u0433\u0438\u043a\u0430 \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0440\u0430\u0444\u043e\u043c, \u043f\u043e \u0440\u0451\u0431\u0440\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u00ab\u0442\u0435\u043a\u0443\u0442\u00bb \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u0443\u0437\u043b\u0430\u0445. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u044f\u0432\u0448\u0435\u0435\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u2013 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u00abdataflow \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443\u00bb. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043e\u043f\u0438\u0448\u0443, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0421++, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"http:\/\/threadingbuildingblocks.org\">Intel\u00ae Threading Building Blocks<\/a> (Intel\u00ae TBB), \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441 tbb::flow::graph.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/509\/186\/e56\/509186e561e7563c4ec5f71709dda868.png\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Intel TBB \u0438 \u043a\u043b\u0430\u0441\u0441 tbb::flow::graph<\/h3>\n<p>  Intel\u00ae Threading Building Blocks \u2013 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0421++ \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0420\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u043d\u043e \u0435\u0441\u0442\u044c \u0438 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f. \u0412 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f Windows*, Linux* \u0438 OS X*.<\/p>\n<p>  \u0412 TBB \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u00ab\u0437\u0430\u0442\u043e\u0447\u0435\u043d\u043d\u044b\u0445\u00bb \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0435\u0441\u0442\u044c \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c. <\/p>\n<p>  \u0413\u0440\u0430\u0444, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d (\u0443\u0437\u043b\u043e\u0432) \u0438 \u0440\u0451\u0431\u0435\u0440. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 tbb::flow::graph \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 (node), \u0440\u0451\u0431\u0435\u0440 (edge) \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u0441\u0435\u0433\u043e \u0433\u0440\u0430\u0444\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a47\/4c1\/957\/a474c1957fba901b5c45dc3c2b4eea01.png\"\/><\/p>\n<p>  \u0423\u0437\u043b\u044b \u0433\u0440\u0430\u0444\u0430 \u0438\u043c\u0435\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u044f, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0420\u0451\u0431\u0440\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442 \u0443\u0437\u043b\u044b \u0433\u0440\u0430\u0444\u0430 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u00ab\u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438\u00bb \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. <\/p>\n<p>  \u0422\u0435\u043b\u043e \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0435\u0439 TBB \u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438, \u0435\u0441\u043b\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043d\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0412 TBB \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b (\u0438\u043b\u0438 \u0432\u0441\u0435) \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u2013 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b (\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u041c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0438 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 CPU, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u2013 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a tbb::flow::graph.<\/p>\n<h3>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0433\u0440\u0430\u0444 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h3>\n<p>  \u0413\u0440\u0430\u0444, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0448\u0438\u043d, \u0441\u043e\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0445 \u043e\u0434\u043d\u0438\u043c \u0440\u0435\u0431\u0440\u043e\u043c, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u201cHello\u201d, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u201cWorld\u201d, \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/56f\/838\/5c3\/56f8385c373be4d654b947856f2e9aab.png\"\/><\/p>\n<p>  \u0410 \u0432 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code>#include &lt;iostream&gt; #include &lt;tbb\/flow_graph.h&gt;  int main(int argc, char *argv[]) { \ttbb::flow::graph g;  \ttbb::flow::continue_node&lt; tbb::flow::continue_msg &gt;  \t\th( g, []( const tbb::flow::continue_msg & ) { std::cout &lt;&lt; &quot;Hello &quot;; } );  \ttbb::flow::continue_node&lt; tbb::flow::continue_msg &gt;  \t\tw( g, []( const tbb::flow::continue_msg & ) { std::cout &lt;&lt; &quot;World\\n&quot;; } );                              \ttbb::flow::make_edge( h, w );  \th.try_put(tbb::flow::continue_msg()); \tg.wait_for_all(); \treturn 0; }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0433\u0440\u0430\u0444\u0430 g \u0438 \u0434\u0432\u0430 \u0443\u0437\u043b\u0430 \u0442\u0438\u043f\u0430 continue_node \u2013 h \u0438 w. \u042d\u0442\u0438 \u0443\u0437\u043b\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 continue_msg \u2013 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0444\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u0442\u0435\u043b\u043e \u0443\u0437\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u0430. <\/p>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 continue_node \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043a\u043e\u0434 \u2013 \u043f\u0435\u0447\u0430\u0442\u044c \u201cHello\u201d \u0438 \u201cWorld\u201d. \u0423\u0437\u043b\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0431\u0440\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 make_edge. \u0412\u0441\u0451, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u2013 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435, \u043f\u043e\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c try_put. \u0414\u0430\u043b\u0435\u0435 \u0433\u0440\u0430\u0444 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u0436\u0434\u0451\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 wait_for_all.<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0433\u0440\u0430\u0444 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/h3>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 x<sup>2<\/sup>+x<sup>3<\/sup> \u0434\u043b\u044f x \u043e\u0442 1 \u0434\u043e 10. \u0414\u0430, \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. <\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0437\u0435\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f x \u0438\u0437 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0443\u0437\u043b\u0430\u043c, \u0432\u043e\u0437\u0432\u043e\u0434\u044f\u0449\u0438\u043c \u0432 \u043a\u0443\u0431 \u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442. \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0434\u0438\u0441\u0431\u0430\u043b\u0430\u043d\u0441\u043e\u0432 \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0441\u0432\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u0443\u0444\u0435\u0440\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0451\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0439 \u0443\u0437\u0435\u043b, \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0437\u043b\u0443, \u043d\u0430 \u0447\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/329\/669\/9ca\/3296699ca74a7a1ad5234a8df1193a63.jpg\"\/><\/p>\n<p>  \u041a\u043e\u0434 \u0442\u0430\u043a\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430:<\/p>\n<pre><code>#include &lt;tbb\/flow_graph.h&gt; #include &lt;windows.h&gt;  using namespace tbb::flow;  struct square {    int operator()(int v) {     printf(&quot;squaring %d\\n&quot;, v);     Sleep(1000);\t\t      return v*v;    } };  struct cube {   int operator()(int v) {      printf(&quot;cubing %d\\n&quot;, v);     Sleep(1000);      return v*v*v;    } };  class sum {   int &my_sum; public:   sum( int &s ) : my_sum(s) {}   int operator()( std::tuple&lt;int,int&gt; v ) {     printf(&quot;adding %d and %d to %d\\n&quot;, std::get&lt;0&gt;(v), std::get&lt;1&gt;(v), my_sum);     my_sum += std::get&lt;0&gt;(v) + std::get&lt;1&gt;(v);     return my_sum;   } };  int main(int argc, char *argv[]) { \tint result = 0;  \tgraph g;  \tbroadcast_node&lt;int&gt; input (g); \tfunction_node&lt;int,int&gt; squarer( g, unlimited, square() ); \tfunction_node&lt;int,int&gt; cuber( g, unlimited, cube() ); \tbuffer_node&lt;int&gt; square_buffer(g); \tbuffer_node&lt;int&gt; cube_buffer(g); \tjoin_node&lt; std::tuple&lt;int,int&gt;, queueing &gt; join(g); \tfunction_node&lt;std::tuple&lt;int,int&gt;,int&gt; \t\tsummer( g, serial, sum(result) );   \tmake_edge( input, squarer ); \tmake_edge( input, cuber ); \tmake_edge( squarer, square_buffer ); \tmake_edge( squarer, input_port&lt;0&gt;(join) ); \tmake_edge( cuber, cube_buffer ); \tmake_edge( cuber, input_port&lt;1&gt;(join)\t\t); \tmake_edge( join, summer );   \tfor (int i = 1; i &lt;= 10; ++i) \t\tinput.try_put(i); \tg.wait_for_all();   \tprintf(&quot;Final result is %d\\n&quot;, result); \treturn 0; }<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f Sleep(1000) \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 Windows, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430\u0445). \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0451 \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u2013 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0443\u0437\u043b\u044b, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u0445 \u0440\u0451\u0431\u0440\u0430\u043c\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 function_node (unlimited \u0438\u043b\u0438 serial) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0442\u0435\u043b\u0430 \u0443\u0437\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0423\u0437\u0435\u043b \u0442\u0438\u043f\u0430 join_node \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445\/\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0445\u043e\u0434\u0435, \u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0433\u043e\u0442\u043e\u0432\u044b \u2013 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0443\u0437\u043b\u0443 \u0432 \u0432\u0438\u0434\u0435 std::tuple.<\/p>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00ab\u043e\u0431\u0435\u0434\u0430\u044e\u0449\u0438\u0445 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u043e\u0432\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e tbb::flow::graph<\/h3>\n<p>  <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%BE%D0%B1%D0%BB%D0%B5%D0%BC%D0%B0_%D0%BE%D0%B1%D0%B5%D0%B4%D0%B0%D1%8E%D1%89%D0%B8%D1%85_%D1%84%D0%B8%D0%BB%D0%BE%D1%81%D0%BE%D1%84%D0%BE%D0%B2\">\u0418\u0437 \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438<\/a>:<br \/>  <i>\u00ab\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0431\u0435\u0434\u0430\u044e\u0449\u0438\u0445 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u043e\u0432\u00bb \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0435 \u0434\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u0442\u0435\u0445\u043d\u0438\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/i><\/p>\n<p>  \u0412 \u0437\u0430\u0434\u0430\u0447\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u043e\u0432 \u0441\u0438\u0434\u044f\u0442 \u0437\u0430 \u0441\u0442\u043e\u043b\u043e\u043c, \u0438 \u043c\u043e\u0433\u0443\u0442 \u043b\u0438\u0431\u043e \u0435\u0441\u0442\u044c, \u043b\u0438\u0431\u043e \u0434\u0443\u043c\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u044b \u0435\u0434\u044f\u0442 \u043b\u0430\u043f\u0448\u0443 \u043f\u0430\u043b\u043e\u0447\u043a\u0430\u043c\u0438 \u2013 \u0447\u0442\u043e\u0431\u044b \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0435 \u043f\u0430\u043b\u043e\u0447\u043a\u0438, \u043d\u043e \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2b2\/e01\/e79\/2b2e01e7962f0b28bcda9286de1f196a.png\"\/><\/p>\n<p>  \u0412 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f deadlock (\u0432\u0437\u0430\u0438\u043c\u043d\u0430\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430), \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442 \u043b\u0435\u0432\u0443\u044e \u043e\u0442 \u0441\u0435\u0431\u044f \u043f\u0430\u043b\u043e\u0447\u043a\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u0435\u0434\u0430\u044e\u0449\u0438\u043c\u0438. <\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u043e\u043b \u0441 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0430\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 tbb::flow::graph. \u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0434\u0432\u0443\u043c\u044f \u0443\u0437\u043b\u0430\u043c\u0438: join_node \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u043f\u0430\u043b\u043e\u0447\u0435\u043a \u0438 function_node \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u00ab\u0435\u0441\u0442\u044c\u00bb \u0438 \u00ab\u0434\u0443\u043c\u0430\u0442\u044c\u00bb. \u041c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u043f\u0430\u043b\u043e\u0447\u043a\u0438 \u043d\u0430 \u0441\u0442\u043e\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0447\u0435\u0440\u0435\u0437 queue_node. \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 queue_node \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043b\u043e\u0447\u043a\u0438, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u2013 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430. \u0413\u0440\u0430\u0444 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c19\/b01\/829\/c19b018297ef19759ae530b00409af62.png\"\/><\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f main \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438:<\/p>\n<pre><code>#include &lt;windows.h&gt; #include &lt;tbb\/flow_graph.h&gt; #include &lt;tbb\/task_scheduler_init.h&gt;  using namespace tbb::flow;  const char *names[] =  { &quot;Archimedes&quot;, &quot;Aristotle&quot;, &quot;Democritus&quot;, &quot;Epicurus&quot;, &quot;Euclid&quot;,  &quot;Heraclitus&quot;, &quot;Plato&quot;, &quot;Pythagoras&quot;, &quot;Socrates&quot;, &quot;Thales&quot; };  \u2026. int main(int argc, char *argv[]) {   int num_threads = 0;   int num_philosophers = 10;   if ( argc &gt; 1 ) num_threads = atoi(argv[1]);   if ( argc &gt; 2 ) num_philosophers = atoi(argv[2]);    if ( num_threads &lt; 1 || num_philosophers &lt; 1 || num_philosophers &gt; 10 ) exit(1);    tbb::task_scheduler_init init(num_threads);   graph g;   printf(&quot;\\n%d philosophers with %d threads\\n\\n&quot;,           num_philosophers, num_threads);    std::vector&lt; queue_node&lt;chopstick&gt; * &gt; places;   for ( int i = 0; i &lt; num_philosophers; ++i ) {     queue_node&lt;chopstick&gt; *qn_ptr = new queue_node&lt;chopstick&gt;(g);     qn_ptr-&gt;try_put(chopstick());     places.push_back( qn_ptr );   }    std::vector&lt; philosopher &gt; philosophers;   for ( int i = 0; i &lt; num_philosophers; ++i ) {     philosophers.push_back( philosopher( names[i], g,                                          places[i],                                           places[(i+1)%num_philosophers] ) );     g.run( philosophers[i] );   }   g.wait_for_all();    for ( int i = 0; i &lt; num_philosophers; ++i ) philosophers[i].check();    return 0; }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0438\u043f\u0430 tbb::task_scheduler_init. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u0433\u0440\u0430\u0444\u0430 g. \u00ab\u041c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043f\u0430\u043b\u043e\u0447\u0435\u043a\u00bb queue_node \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 std::vector, \u0438 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0430\u043b\u043e\u0447\u043a\u0435.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u044b \u2013 \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 std::vector. \u041e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 run \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0433\u0440\u0430\u0444\u0430. \u041a\u043b\u0430\u0441\u0441 philosopher \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c operator(), \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f run \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435, \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0439 \u043a \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0433\u0440\u0430\u0444\u0430 g. \u0422\u0430\u043a \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432\u0430 g.wait_for_all(). <\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 philosopher:<\/p>\n<pre><code>const int think_time = 1000;  const int eat_time = 1000;  const int num_times = 10;   class chopstick {};   class philosopher {  public:     typedef queue_node&lt; chopstick &gt; chopstick_buffer;    typedef join_node&lt; std::tuple&lt;chopstick,chopstick&gt; &gt; join_type;     philosopher( const char *name, graph &the_graph,                chopstick_buffer *left, chopstick_buffer *right ) :    my_name(name), my_graph(&the_graph),   my_left_chopstick(left), my_right_chopstick(right),   my_join(new join_type(the_graph)), my_function_node(NULL),   my_count(new int(num_times)) {}     void operator()();    void check();   private:     const char *my_name;    graph *my_graph;    chopstick_buffer *my_left_chopstick;    chopstick_buffer *my_right_chopstick;    join_type *my_join;    function_node&lt; join_type::output_type, continue_msg &gt; *my_function_node;    int *my_count;     friend class node_body;     void eat_and_think( );    void eat( );    void think( );    void make_my_node();   };<\/code><\/pre>\n<p>  \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0430 \u0435\u0441\u0442\u044c \u0438\u043c\u044f, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0433\u0440\u0430\u0444\u0430 \u0438 \u043d\u0430 \u043b\u0435\u0432\u0443\u044e \u0438 \u043f\u0440\u0430\u0432\u0443\u044e \u043f\u0430\u043b\u043e\u0447\u043a\u0438, \u0443\u0437\u0435\u043b join_node, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0437\u0435\u043b function_node \u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a my_count, \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u0434\u0443\u043c\u0430\u043b \u0438 \u0435\u043b. <\/p>\n<p>  operator()(), \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 run \u0433\u0440\u0430\u0444\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0443\u043c\u0430\u043b, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u043b \u0441\u0435\u0431\u044f \u043a \u0433\u0440\u0430\u0444\u0443.<\/p>\n<pre><code>void philosopher::operator()() {    think();    make_my_node();  }   \u041c\u0435\u0442\u043e\u0434\u044b think \u0438 eat \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u044f\u0442 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f: void philosopher::think() {    printf(&quot;%s thinking\\n&quot;, my_name );    Sleep(think_time);    printf(&quot;%s done thinking\\n&quot;, my_name );  }   void philosopher::eat() {    printf(&quot;%s eating\\n&quot;, my_name );    Sleep(eat_time);    printf(&quot;%s done eating\\n&quot;, my_name );  }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 make_my_node \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0437\u0435\u043b, \u0438 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438 \u0435\u0433\u043e, \u0438 join_node \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0433\u0440\u0430\u0444\u043e\u043c:<\/p>\n<pre><code>void philosopher::make_my_node() {    my_left_chopstick-&gt;register_successor( input_port&lt;0&gt;(*my_join) );    my_right_chopstick-&gt;register_successor( input_port&lt;1&gt;(*my_join) );    my_function_node =      new function_node&lt; join_type::output_type, continue_msg &gt;( *my_graph,        serial, node_body( *this ) );    make_edge( *my_join, *my_function_node );  }<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0433\u0440\u0430\u0444 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u2013 \u0440\u0435\u0431\u0440\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c register_successor. \u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0433\u0440\u0430\u0444\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u0412 TBB \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043d\u0430 \u043b\u0435\u0442\u0443, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0444 \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u2013 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b. \u042d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430.<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 node_body \u2014 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0442\u043e\u0440, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 philosopher::eat_and_think():<\/p>\n<pre><code>class node_body {    philosopher &my_philosopher;  public:    node_body( philosopher &p ) : my_philosopher(p) { }    void operator()( philosopher::join_type::output_type ) {      my_philosopher.eat_and_think();    }  };<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 eat_and_think \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e eat() \u0438 \u0434\u0435\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0447\u0451\u0442\u0447\u0438\u043a. \u0414\u0430\u043b\u044c\u0448\u0435 \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u043a\u043b\u0430\u0434\u0451\u0442 \u0441\u0432\u043e\u0438 \u043f\u0430\u043b\u043e\u0447\u043a\u0438 \u043d\u0430 \u0441\u0442\u043e\u043b \u0438 \u0434\u0443\u043c\u0430\u0435\u0442. \u0410 \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u043e\u0435\u043b \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437, \u043e\u043d \u0432\u0441\u0442\u0430\u0451\u0442 \u0438\u0437-\u0437\u0430 \u0441\u0442\u043e\u043b\u0430 \u2013 \u0440\u0430\u0437\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u0438 \u0441\u0432\u043e\u0435\u0433\u043e join_node \u0441 \u0433\u0440\u0430\u0444\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c remove_successor. \u0417\u0434\u0435\u0441\u044c \u043e\u043f\u044f\u0442\u044c \u0432\u0438\u0434\u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0433\u0440\u0430\u0444\u0430 \u2013 \u0447\u0430\u0441\u0442\u044c \u0443\u0437\u043b\u043e\u0432 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.<\/p>\n<pre><code>void philosopher::eat_and_think( ) {    eat();    --(*my_count);     if (*my_count &gt; 0) {      my_left_chopstick-&gt;try_put( chopstick() );      my_right_chopstick-&gt;try_put( chopstick() );      think();    } else {      my_left_chopstick-&gt;remove_successor( input_port&lt;0&gt;(*my_join) );     my_right_chopstick-&gt;remove_successor( input_port&lt;1&gt;(*my_join) );     my_left_chopstick-&gt;try_put( chopstick() );      my_right_chopstick-&gt;try_put( chopstick() );    }  }<\/code><\/pre>\n<p>  \u0412 \u043d\u0430\u0448\u0435\u043c \u0433\u0440\u0430\u0444\u0435 \u0435\u0441\u0442\u044c \u0440\u0435\u0431\u0440\u043e \u043e\u0442 queue_node (\u043c\u0435\u0441\u0442\u0430 \u0434\u043b\u044f \u043f\u0430\u043b\u043e\u0447\u043a\u0438) \u043a \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0443, \u0442\u043e\u0447\u043d\u0435\u0435 \u0435\u0433\u043e join_node. \u0410 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u043d\u0435\u0442. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u0435\u0442\u043e\u0434 eat_and_think \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c try_put \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0430\u043b\u043e\u0447\u043a\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main() \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 check, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u043f\u043e\u0435\u043b \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u00ab\u043e\u0447\u0438\u0441\u0442\u043a\u0443\u00bb:<\/p>\n<pre><code>void philosopher::check() {    if ( *my_count != 0 ) {      printf(&quot;ERROR: philosopher %s still had to run %d more times\\n&quot;, my_name, *my_count);      exit(1);    } else {      printf(&quot;%s done.\\n&quot;, my_name);    }    delete my_function_node;    delete my_join;    delete my_count;  }<\/code><\/pre>\n<p>  Deadlock \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e join_node. \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u0443\u0437\u043b\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 std::tuple \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0441 \u043e\u0431\u043e\u0438\u0445 \u0432\u0445\u043e\u0434\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0438. join_node \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u0432\u0445\u043e\u0434\u0430\u0445, \u043f\u043e\u0442\u043e\u043c \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0445 \u0437\u0430\u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0415\u0441\u043b\u0438 \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430 \u2013 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u044e\u0442\u0441\u044f\u00bb \u0438 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f std::tuple. \u0415\u0441\u043b\u0438 \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u00ab\u043a\u0430\u043d\u0430\u043b\u0430\u00bb \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u2013 \u0442\u0435, \u0447\u0442\u043e \u0443\u0436\u0435 \u0437\u0430\u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f. \u0422.\u0435. \u0435\u0441\u043b\u0438 \u0444\u0438\u043b\u043e\u0441\u043e\u0444 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u043f\u0430\u043b\u043e\u0447\u043a\u0443, \u043d\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043d\u044f\u0442\u0430 \u2013 \u043e\u043d \u043e\u0442\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u0443\u044e \u0438 \u043f\u043e\u0434\u043e\u0436\u0434\u0451\u0442, \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044f \u0441\u043e\u0441\u0435\u0434\u0435\u0439 \u043f\u043e\u043d\u0430\u043f\u0440\u0430\u0441\u043d\u0443. <\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043e\u0431\u0435\u0434\u0430\u044e\u0449\u0438\u043c\u0438 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0430\u043c\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 TBB \u0433\u0440\u0430\u0444\u0430:  <\/p>\n<ul>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 join_node \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c<\/li>\n<li>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0430 \u2013 \u0443\u0437\u043b\u044b \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b <\/li>\n<li>\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0435\u0434\u0438\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0432\u0445\u043e\u0434\u0430 \u0438 \u0432\u044b\u0445\u043e\u0434\u0430, \u0433\u0440\u0430\u0444 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043f\u0435\u0442\u043b\u0438<\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 run \u0433\u0440\u0430\u0444\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0422\u0438\u043f\u044b \u0443\u0437\u043b\u043e\u0432<\/h3>\n<p>  tbb::flow::graph \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0448\u0438\u0440\u043e\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0443\u0437\u043b\u043e\u0432. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0433\u0440\u0443\u043f\u043f\u044b: \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 (functional), \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0443\u044e\u0449\u0438\u0435, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0449\u0438\u0435 \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0435, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435. \u0421\u043f\u0438\u0441\u043e\u043a \u0442\u0438\u043f\u043e\u0432 \u0443\u0437\u043b\u043e\u0432 \u0441 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u043c\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/4a9\/9b6\/a51\/4a99b6a5163b47bf19a56733396ebd32.png\"\/><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0444\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 Intel TBB, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u00ab\u043d\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u043e\u043c\u00bb. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438, \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. <\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0433\u0440\u0430\u0444\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0442\u0430\u043a \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u2013 \u0443\u0437\u043b\u044b \u0438 \u0440\u0451\u0431\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u00ab\u043d\u0430 \u043b\u0435\u0442\u0443\u00bb. \u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0433\u0440\u0430\u0444\u044b \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u0431\u0430\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0438\u0445 \u0437\u0430\u043e\u043a\u0435\u0430\u043d\u0441\u043a\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435:<\/p>\n<p>  \u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Intel\u00ae Threading Building Blocks (\u0412\u0435\u0440\u0441\u0438\u044f \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c):<br \/>  <a href=\"http:\/\/threadingbuildingblocks.org\">http:\/\/threadingbuildingblocks.org<\/a><\/p>\n<p>  \u041a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f Intel TBB (\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f):<br \/>  <a href=\"http:\/\/software.intel.com\/en-us\/intel-tbb\">http:\/\/software.intel.com\/en-us\/intel-tbb<\/a><\/p>\n<p>  \u0410\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0431\u043b\u043e\u0433\u0438 \u043e tbb::flow::graph:<br \/>  <a href=\"http:\/\/software.intel.com\/en-us\/tags\/17218\">http:\/\/software.intel.com\/en-us\/tags\/17218<\/a> <br \/>  <a href=\"http:\/\/software.intel.com\/en-us\/tags\/17455\">http:\/\/software.intel.com\/en-us\/tags\/17455<\/a>    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/intel\/blog\/157735\/\"> http:\/\/habrahabr.ru\/company\/intel\/blog\/157735\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0415\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u2013 \u0431\u043b\u043e\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u00ab\u0441\u0438\u0433\u043d\u0430\u043b\u044b\u00bb \u0438 \u0442.\u0434. \u041b\u043e\u0433\u0438\u043a\u0430 \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438 \u0441\u0432\u044f\u0437\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0440\u0430\u0444\u043e\u043c, \u043f\u043e \u0440\u0451\u0431\u0440\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u00ab\u0442\u0435\u043a\u0443\u0442\u00bb \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0432 \u0443\u0437\u043b\u0430\u0445. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u044f\u0432\u0448\u0435\u0435\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u2013 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0438 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u00abdataflow \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443\u00bb. <\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043e\u043f\u0438\u0448\u0443, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0421++, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"http:\/\/threadingbuildingblocks.org\">Intel\u00ae Threading Building Blocks<\/a> (Intel\u00ae TBB), \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441 tbb::flow::graph.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/509\/186\/e56\/509186e561e7563c4ec5f71709dda868.png\"\/>  <\/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-157735","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157735","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=157735"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/157735\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}