{"id":271374,"date":"2015-12-29T19:54:02","date_gmt":"2015-12-29T16:54:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=271374"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=271374","title":{"rendered":"Rayon: \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rust"},"content":{"rendered":"<p>       \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/\">Rayon<\/a> \u2014 \u043c\u043e\u0435\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f <strong>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong> \u0432 Rust.<br \/>  \u042f \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0432\u043e\u043b\u0435\u043d \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0434\u0451\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043a \u0447\u0435\u043c\u0443 \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u0432 \u0431\u043b\u043e\u0433 \u043f\u043e\u0441\u0442\u0435.<br \/>  <strong>\u0426\u0435\u043b\u044c Rayon \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u044b\u043c,<\/strong> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u043a\u043b <code>for<\/code> \u0438\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code class=\"rust\">let total_price = stores.iter()                         .map(|store| store.compute_price(&amp;list))                         .sum() <\/code><\/pre>\n<p>  \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0451 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <em>\u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u00bb<\/em> \u043d\u0430 <em>\u00ab\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u00bb<\/em> \u0438\u0437 Rayon:<\/p>\n<pre><code class=\"rust\">let total_price = stores.par_iter()                         .map(|store| store.compute_price(&amp;list))                         .sum() <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u0430\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0449\u0451 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c. <strong>Rayon \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e API \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0433\u043e\u043d\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/strong><br \/>  \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b Rayon. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 Rayon (<code>join<\/code>), \u0430 \u0437\u0430\u0442\u0435\u043c \u2014 \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d.<br \/>  \u042f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0444\u0438\u0447 Rust \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>join<\/code> \u0441 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0438\u043c\u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u043c\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0430\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u0433\u0438\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0417\u0430\u0442\u0435\u043c \u044f \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>join<\/code> \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c, \u0447\u0442\u043e Rayon \u0432 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <em>\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/em>. \u042f \u043e\u0436\u0438\u0434\u0430\u044e, \u0447\u0442\u043e \u0434\u0438\u0437\u0430\u0439\u043d \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0435\u0449\u0451 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u0441\u043a\u0430\u0436\u0435\u043c \u0442\u0430\u043a, \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 (\u043a\u0430\u043b\u0430\u043c\u0431\u0443\u0440 \u043d\u0435 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u044b\u0439), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0438\u0431\u043a\u0430\u044f, \u043a\u0430\u043a \u044f \u0431\u044b \u0442\u043e\u0433\u043e \u0445\u043e\u0442\u0435\u043b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u043d\u0438\u043a\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0418 \u0432\u0441\u0451 \u0436\u0435 Rayon \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441. \u0427\u0435\u043c\u0443 \u044f \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434, \u043a\u0430\u043a, \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0431\u0443\u0434\u0435\u0442\u0435 \u0440\u0430\u0434\u044b \u0438 \u0432\u044b!<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 Rayon: join<\/h3>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0430 \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 map-reduce:<\/p>\n<pre><code class=\"rust\">let total_price = stores.par_iter()                         .map(|store| store.compute_price(&amp;list))                         .sum() <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u2014 \u043b\u0438\u0448\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0430, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0431\u043e\u043b\u0435\u0435 \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u0430: <code>join<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>join<\/code> \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u0412\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u0434\u0432\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435, \u0438 <code>join<\/code> <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e<\/em> \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0438\u0445 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043e\u0431\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044f, \u043e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"rust\">\/\/ `do_something` \u0438 `do_something_else` *\u043c\u043e\u0433\u0443\u0442* \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e join(|| do_something(), || do_something_else()) <\/code><\/pre>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0442\u0443\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0432\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043c\u043e\u0433\u0443\u0442<\/em> \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e: <strong>\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u044f\u0434\u0440\u0430, \u0438\u043b\u0438 \u043d\u0435\u0442.<\/strong> \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>join<\/code> \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0442\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438 \u0435\u0433\u043e, \u0438\u043b\u0438 \u043d\u0435\u0442.<br \/>  \u041f\u043e\u0434\u0445\u043e\u0434 <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430<\/em> \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442 Rayon \u043e\u0442 <a href=\"https:\/\/github.com\/aturon\/crossbeam\/blob\/master\/src\/scoped.rs\">\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 crossbeam<\/a>. \u0415\u0441\u043b\u0438 \u0432 crossbeam \u0432\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0434\u0432\u0443\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c, \u0442\u043e \u043e\u043d\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u0437\u043e\u0432 <code>join<\/code> \u0432 Rayon \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 API, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u0412\u0441\u0451 \u043e\u0442\u0442\u043e\u0433\u043e, \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u044b\u0433\u043e\u0434\u043d\u044b\u043c, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0449\u0451 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f? <strong>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u2014 \u043f\u0440\u043e\u043f\u0430\u0433\u0430\u043d\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c<\/em> \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rust,<\/strong> \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <em>\u0433\u0430\u043d\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u043d\u0435\u0435.<br \/>  \u042d\u0442\u043e \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u043e\u043b\u0438 \u0434\u043b\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 crossbeam, \u043d\u0435\u0442. \u0421\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 <em>\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430<\/em> \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432\u044b \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043d\u0430\u043b \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438 \u0432 <code>join<\/code>, \u0442\u043e \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 (deadlock). \u041e <code>join<\/code> \u0441\u0442\u043e\u0438\u0442 \u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e <em>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435<\/em>. (\u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u043e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0432\u0440\u043e\u0434\u0435 <code>Mutex<\/code>, <code>AtomicU32<\/code> \u0438 \u0442.\u0434. \u0438\u0437\u043d\u0443\u0442\u0440\u0438 <code>join<\/code> \u2014 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u043d\u043e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435 <em>\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c<\/em> \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e.)<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f join: \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 quicksort<\/h3>\n<p>  \u041f\u0440\u0438\u043c\u0438\u0442\u0438\u0432 <code>join<\/code> \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438\u0437 \u0441\u0435\u0440\u0438\u0438 <em>\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439<\/em>. \u042d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/test.rs#L6-L28\">\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e quicksort<\/a>:<\/p>\n<pre><code class=\"rust\">fn quick_sort&lt;T:PartialOrd+Send&gt;(v: &amp;mut [T]) {     if v.len() &gt; 1 {         let mid = partition(v);         let (lo, hi) = v.split_at_mut(mid);         rayon::join(|| quick_sort(lo),                     || quick_sort(hi));     } } fn partition&lt;T:PartialOrd+Send&gt;(v: &amp;mut [T]) -&gt; usize {     \/\/ \u0441\u043c. https:\/\/en.wikipedia.org\/wiki\/Quicksort#Lomuto_partition_scheme } <\/code><\/pre>\n<p>  \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 quicksort \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>rayon::join<\/code>!<\/p>\n<h3>\u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d join: \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b (work-stealing)<\/h3>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 <code>join<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0445\u043d\u0438\u043a\u0438, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043a\u0430\u043a <strong>\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b.<\/strong> \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u044b\u043b \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cilk\">Cilk<\/a>, \u0438 \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u0441\u0442\u0430\u043b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u043e\u0439 (\u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 Rayon <em>(\u0430\u043d\u0433\u043b. \u00ab\u0432\u0438\u0441\u043a\u043e\u0437\u0430\u00bb \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.)<\/em> \u2014 \u0434\u0430\u043d\u044c \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u044f Cilk).<br \/>  \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 <code>join(a, b)<\/code> \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 <code>a<\/code> \u0438 <code>b<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u043c\u044b \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438. \u0412\u0441\u0451, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 <code>b<\/code> \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c <em>\u00ab\u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b\u00bb<\/em>, \u0430 \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0440\u0451\u0442, \u0438 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 <code>a<\/code>. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0443\u043b \u0434\u0440\u0443\u0433\u0438\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u044f\u0434\u0440\u043e \u0426\u041f, \u0438\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 \u0442\u043e\u0433\u043e). \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u043e\u043d \u0438\u0434\u0451\u0442 \u0438 \u043a\u043e\u043f\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445 <em>\u00ab\u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b\u00bb<\/em> \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432: \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0435\u0451 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0451 \u0441\u0430\u043c. \u0422\u0430\u043a \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u043a\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u043d\u044f\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c <code>a<\/code>, \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 <code>b<\/code>.<br \/>  \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442 <code>a<\/code>, \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442: \u043d\u0430\u0447\u0430\u043b \u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c <code>b<\/code>? \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0435\u0451 \u0441\u0430\u043c. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0435\u0451 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442. \u041d\u043e \u043f\u043e\u043a\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0436\u0434\u0451\u0442, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0439\u0442\u0438, \u0438 \u0441\u0442\u0430\u0449\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0441\u0442\u0432\u0443\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0446\u0435\u043b\u043e\u043c.<br \/>  \u0412 \u0432\u0438\u0434\u0435 Rust-\u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u0430 <code>join<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a (<a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/api.rs#L23-L64\">\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043a\u043e\u0434<\/a> \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442):<\/p>\n<pre><code class=\"python\">fn join&lt;A,B&gt;(oper_a: A, oper_b: B)     where A: FnOnce() + Send,         B: FnOnce() + Send, {     \/\/ \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c `oper_b` \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c, \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u0435\u0451 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c:     let job = push_onto_local_queue(oper_b);      \/\/ \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c `oper_a` \u0441\u0430\u043c\u0438:     oper_a();      \/\/ Check whether anybody stole `oper_b`:     if pop_from_local_queue(oper_b) {         \/\/ \u041d\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u0430, \u0432\u044b\u043f\u043e\u043b\u044f\u0435\u043c \u0441\u0430\u043c\u0438.         oper_b();     } else {         \/\/ \u041f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u0430, \u0436\u0434\u0451\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0435\u0451 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.         \/\/ \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0443 \u0434\u0440\u0443\u0433\u0438\u0445:         while not_yet_complete(job) {             steal_from_others();         }         result_b = job.result();     } } <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0430\u043a\u0438\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c, \u0442\u0430\u043a \u044d\u0442\u043e \u0435\u0433\u043e \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u044f \u043a \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0426\u041f. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0437\u0430\u043d\u044f\u0442\u044b, \u0442\u043e <code>join(a, b)<\/code> \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e (\u0442. \u0435. <code>a(); b();<\/code>), \u0447\u0442\u043e \u043d\u0435 \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434. \u041d\u043e \u0435\u0441\u043b\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 <em>\u0435\u0441\u0442\u044c<\/em>, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0417\u0430\u043c\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  Rayon \u0432\u0441\u0451 \u0435\u0449\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043e\u043b\u043e\u0434, \u0442\u0430\u043a \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c (\u0438 \u044f \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043e\u0441\u043e\u0431\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b). \u041d\u0435 \u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c <em>\u043d\u0435\u043c\u043d\u043e\u0433\u043e<\/em> \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043e\u0442\u043b\u0430\u0434\u043a\u0443, \u0447\u0435\u043c \u043c\u043d\u0435 \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/demo\/quicksort\/src\/main.rs#L47-L60\">\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 quicksort<\/a> \u044f \u0432\u0438\u0436\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Speedup#Speedup_in_latency\">\u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u043e\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/a> \u043d\u0430 \u043c\u043e\u0451\u043c 4-\u0445\u044f\u0434\u0435\u0440\u043d\u043e\u043c Macbook Pro (\u0442\u0430\u043a \u0447\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c):  <\/p>\n<table>\n<tr>\n<th> \u0414\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <\/th>\n<th> \u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 <\/th>\n<\/tr>\n<tr>\n<td> 1K <\/td>\n<td> 0.95x <\/td>\n<\/tr>\n<tr>\n<td> 32K <\/td>\n<td> 2.19x <\/td>\n<\/tr>\n<tr>\n<td> 64K <\/td>\n<td> 3.09x <\/td>\n<\/tr>\n<tr>\n<td> 128K <\/td>\n<td> 3.52x <\/td>\n<\/tr>\n<tr>\n<td> 512K <\/td>\n<td> 3.84x <\/td>\n<\/tr>\n<tr>\n<td> 1024K <\/td>\n<td> 4.01x <\/td>\n<\/tr>\n<\/table>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u2014 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b <em>\u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443<\/em>. \u0421\u0443\u0442\u044c \u0442\u0430\u043a\u043e\u0432\u0430, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b (\u0432 \u043c\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u2014 \u043c\u0435\u043d\u0435\u0435 5000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432), \u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u044f\u0441\u044c \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 <code>join<\/code>. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u0430\u0436\u0435\u0439, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/demo\/quicksort\/src\/main.rs#L47-L60\">\u043a\u043e\u0434\u0430 \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/a>. (\u0415\u0441\u043b\u0438 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e \u0438\u0434\u0435\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.)<br \/>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u0435\u043d \u043c\u0435\u043d\u0435\u0435 \u0447\u0430\u0441\u0442\u043e, \u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 API (\u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435) \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0437\u0430 \u0432\u0430\u0441, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e \u044d\u0442\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c.<br \/>  \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b <em>\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0435<\/em> \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0435 \u0442\u0430\u043a\u0438\u043c\u0438 \u0445\u043e\u0440\u043e\u0448\u0438\u043c\u0438, \u0445\u043e\u0442\u044f \u043e\u043d\u0438 \u0438 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0431\u044b\u0442\u044c \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0445\u0443\u0436\u0435:  <\/p>\n<table>\n<tr>\n<th> \u0414\u043b\u0438\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 <\/th>\n<th> \u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 <\/th>\n<\/tr>\n<tr>\n<td> 1K <\/td>\n<td> 0.41x <\/td>\n<\/tr>\n<tr>\n<td> 32K <\/td>\n<td> 2.05x <\/td>\n<\/tr>\n<tr>\n<td> 64K <\/td>\n<td> 2.42x <\/td>\n<\/tr>\n<tr>\n<td> 128K <\/td>\n<td> 2.75x <\/td>\n<\/tr>\n<tr>\n<td> 512K <\/td>\n<td> 3.02x <\/td>\n<\/tr>\n<tr>\n<td> 1024K <\/td>\n<td> 3.10x <\/td>\n<\/tr>\n<\/table>\n<p>  \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0434\u0430 <strong>\u043e\u0442\u0434\u0430\u0451\u0442 \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0441\u0435 \u043f\u043e\u0434\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b<\/strong>. \u0415\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u0438\u043d\u043e\u0439 512K \u0438\u043b\u0438 1024K, \u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0434\u0430\u0447, \u043d\u043e \u043c\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0438 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e 3.10x. \u042f \u0434\u0443\u043c\u0430\u044e, \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0445\u043e\u0440\u043e\u0448\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <em>\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/em> \u0432\u0435\u0440\u043d\u044b\u0439: Rayon \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418 \u0432\u0441\u0451 \u0436\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0447\u0435\u043c 0.41x \u0434\u043b\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u043b\u0438\u043d\u043e\u0439 1K (\u0438 \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e).<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u0447 Rust \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432<\/h3>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u044b\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0445\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0447\u0435\u0439, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0447\u0435\u043d\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u0430 \u0437\u0430\u0434\u0430\u0447. API Rayon \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0438\u0447\u0438 Rust \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432:  <\/p>\n<ul>\n<li><code>join<\/code> \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0435\u043d \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439 \u0441\u0432\u043e\u0438\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0410 \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043c\u043e\u043d\u043e\u043c\u043e\u0440\u0444\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 <code>join<\/code> <strong>\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430<\/strong>. \u0427\u0442\u043e \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 <code>join<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>oper_a()<\/code> \u0438 <code>oper_b()<\/code> (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f), \u0432\u044b\u0437\u043e\u0432\u044b \u0434\u0438\u0441\u043f\u0435\u0442\u0447\u0435\u0440\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0438\u043d\u043b\u0430\u0439\u043d\u0435\u043d\u044b. \u0414\u0430, \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438.<\/li>\n<li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>join<\/code> \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u043e\u0438\u0445 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c <strong>\u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435<\/strong>. \u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 API, \u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 quicksort \u0432\u044b\u0448\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0440\u0435\u0437\u0443 <code>&amp;mut [T]<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0432\u0445\u043e\u0434, \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0435 \u0432 <code>join<\/code>. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <code>join<\/code> \u043c\u043e\u0436\u0435\u0442 <strong>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0437 \u043a\u0443\u0447\u0438<\/strong> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0435\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043b\u0430\u0434\u0443\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a\u0435).<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0432\u044b\u0448\u0435\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u0435, \u0445\u043e\u0442\u044f \u0438 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b. \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0438\u0445 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435:  <\/p>\n<ul>\n<li>\u041c\u043d\u043e\u0433\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u043f\u0440\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 <a href=\"http:\/\/dl.acm.org\/citation.cfm?id=2629643\">\u041b\u0435\u043d\u0438\u0432\u043e\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u0422\u0437\u0430\u043d\u043d\u0435\u0441\u0430 (Tzannes) \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 (\u0442\u0430\u043c \u043e\u043d\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u044b <em>\u00ab\u0433\u043e\u043b\u043e\u0434\u043d\u044b\u043c\u0438\u00bb<\/em> \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438), \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443.<\/li>\n<li>\u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0434\u043e\u0431\u0440\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u044f \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u043d\u0435 <em>\u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043b<\/em> \u0432 \u0431\u0438\u0442\u043a\u043e\u0434 LLVM \u0438\u043b\u0438 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 <code>join<\/code>, \u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u0442\u0430\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e.<\/li>\n<\/ul>\n<h3>\u0421\u0432\u043e\u0431\u043e\u0434\u0430 \u043e\u0442 \u0433\u043e\u043d\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u0447\u0442\u043e Rayon \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u0443 \u043e\u0442 \u0433\u043e\u043d\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0432 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434, \u043d\u0435 \u0432\u043e\u043b\u043d\u0443\u044f\u0441\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435, \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0431\u0430\u0433\u0438.<br \/>  \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043e\u0448\u0438\u0431\u043e\u043a, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0432\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u044f \u0438\u0437\u043c\u0435\u043d\u044e \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u043d (\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e) \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>quick_sort<\/code> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <code>lo<\/code> \u0432 \u043e\u0431\u043e\u0438\u0445 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u0445, \u0442\u043e \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"rust\">fn quick_sort&lt;T:PartialOrd+Send&gt;(v: &amp;mut [T]) {     if v.len() &gt; 1 {         let mid = partition(v);         let (lo, hi) = v.split_at_mut(mid);         rayon::join(|| quick_sort(lo),                     || quick_sort(lo)); \/\/ &lt;-- oops     } } <\/code><\/pre>\n<p>  \u0418 \u0432\u043f\u0440\u0430\u0432\u0434\u0443, \u044f \u0443\u0432\u0438\u0436\u0443 \u0442\u0430\u043a\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"rust\">test.rs:14:10: 14:27 error: closure requires unique access to `lo` but it is already borrowed [E0500] test.rs:14          || quick_sort(lo));                     ^~~~~~~~~~~~~~~~~ <\/code><\/pre>\n<p>  \u041f\u043e\u0445\u043e\u0436\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0435\u0441\u043b\u0438 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0432 \u043e\u0434\u043d\u043e\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <code>lo<\/code> (\u0438\u043b\u0438 <code>hi<\/code>), \u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u2014 <code>v<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0431\u043e\u0438\u043c\u0438 \u0441\u0440\u0435\u0437\u0430\u043c\u0438.<br \/>  <em>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<\/em> \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0431\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u043e\u0434\u043d\u0430\u0436\u0434\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b (\u0438\u043b\u0438, \u0441\u043a\u043e\u0440\u0435\u0435, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0431\u044b) \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u043e\u0437\u0436\u0435. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u043a\u043e\u043f\u0438-\u043f\u0430\u0441\u0442\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e Rust \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0445 \u0432 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0430 \u043d\u0435 \u0432 \u0431\u0430\u0433 \u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<br \/>  \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0438\u0434 \u0431\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u0432\u0438\u0442\u044c \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0439 \u0432 <code>join<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Rust \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 <a href=\"http:\/\/doc.rust-lang.org\/std\/rc\/struct.Rc.html\">\u0442\u0438\u043f \u0441 \u043d\u0435\u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u043c \u0441\u0441\u044b\u043b\u043e\u043a<\/a> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <code>Rc<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>Rc<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435\u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0441\u0441\u044b\u043b\u043e\u043a, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c <code>Rc<\/code> \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0434\u0432\u043e\u0439\u043d\u043e\u043c\u0443 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043b\u0438 \u0447\u0435\u043c\u0443 \u043f\u043e\u0445\u0443\u0436\u0435:<\/p>\n<pre><code class=\"rust\">fn share_rc&lt;T:PartialOrd+Send&gt;(rc: Rc&lt;i32&gt; {     \/\/ \u0412 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u0445 \u043d\u0438\u0436\u0443 \u0432\u044b\u0437\u043e\u0432\u044b `clone` \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0442 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0438 \u0441\u0441\u044b\u043b\u043e\u043a.     \/\/ \u042d\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u044b \u041c\u041e\u0413\u0423\u0422 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e.     \/\/ \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e!     rayon::join(|| something(rc.clone()),                 || something(rc.clone())); } <\/code><\/pre>\n<p>  \u041d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u044e\u0441\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043f\u043e\u043b\u0443\u0447\u0443 \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"rust\">test.rs:14:5: 14:9 error: the trait `core::marker::Sync` is not implemented                         for the type `alloc::rc::Rc&lt;i32&gt;` [E0277] test.rs:14     rayon::join(|| something(rc.clone()),             ^~~~~~~~~~~ test.rs:14:5: 14:9 help: run `rustc --explain E0277` to see a detailed explanation test.rs:14:5: 14:9 note: `alloc::rc::Rc&lt;i32&gt;` cannot be shared between threads safely <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 <em>\u00abnote\u00bb&quot;<\/em> \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>Rc<\/code> \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<br \/>  \u0412\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0442\u0451\u043c\u043d\u0430\u044f \u043c\u0430\u0433\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>join<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430? \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043e\u0442\u0432\u0435\u0442 \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u041f\u0435\u0440\u0432\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 <code>&amp;mut<\/code>-\u0441\u0440\u0435\u0437 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 Rust: \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 <code>&amp;mut<\/code>-\u0441\u0440\u0435\u0437\u0443 <em>(\u0441\u0440\u0435\u0437\u0443 \u0441 \u043f\u0440\u0430\u0432\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.)<\/em>. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>&amp;mut<\/code>-\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c <em>\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c<\/em>, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0435\u0441\u043b\u0438 \u0431\u044b \u0443 \u0432\u0430\u0441 \u0434\u0432\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <em>\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439<\/em> \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 <code>&amp;mut<\/code>-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0442\u0430\u043a\u0438\u043c \u0443\u0436 <em>\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c<\/em>.<br \/>  (\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u0434\u043d\u043e \u0438\u0437 <a href=\"http:\/\/smallcultfollowing.com\/babysteps\/blog\/2013\/06\/11\/on-the-connection-between-memory-management-and-data-race-freedom\/\">\u0432\u0435\u043b\u0438\u0447\u0430\u0439\u0448\u0438\u0445 \u043f\u0440\u043e\u0437\u0440\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043c\u0435\u043d\u044f<\/a> \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0442\u0438\u043f\u043e\u0432 Rust. \u0414\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e <em>\u00ab\u0432\u0438\u0441\u044f\u0447\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438\u00bb<\/em> \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0445 \u0438 <em>\u00ab\u0433\u043e\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445\u00bb<\/em> \u2014 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0431\u0430\u0433\u0438, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0438\u0445 \u043a\u0430\u043a \u0434\u0432\u0435 \u0433\u043e\u043b\u043e\u0432\u044b \u043e\u0434\u043d\u043e\u0439 \u0413\u0438\u0434\u0440\u044b. \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u0430 \u0432\u0438\u0434\u0430 \u044d\u0442\u0438\u0445 \u0431\u0430\u0433\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0431\u0435\u0437\u0443\u0434\u0435\u0440\u0436\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u043e\u0432 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u043e\u0431\u0430 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f. \u041b\u043e\u0432\u043a\u043e, \u0434\u0430?)<br \/>  \u0422\u0430\u043a \u0447\u0442\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0430\u0442\u044c <code>Rc<\/code> \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438? \u041e\u043d\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043e\u0442\u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>join<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0430 \u0435\u0451 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430-\u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u043b\u0438 \u0442\u0438\u043f\u0430\u0436\u0443 <code>Send<\/code>. \u0422\u0438\u043f\u0430\u0436 <code>Send<\/code> \u0432 Rust \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438. \u0422\u0430\u043a \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 <code>join<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u043e\u0431\u0430 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u0442\u0438\u043f\u0430\u0436\u0443 <code>Send<\/code>, \u043e\u043d\u0430 \u043a\u0430\u043a \u0431\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u0442: <em>\u00ab\u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f, \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439\u00bb<\/em>.<\/p>\n<h3>\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/h3>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043e\u0441\u0442\u0430 \u044f \u0434\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c:<\/p>\n<pre><code class=\"rust\">let total_price = stores.par_iter()                         .map(|store| store.compute_price(&amp;list))                         .sum(); <\/code><\/pre>\n<p>  \u041d\u043e \u0441 \u0442\u0435\u0445 \u043f\u043e\u0440 \u044f \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 <code>join<\/code>. \u041a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0440\u0430\u043d\u0435\u0435, API \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/tree\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\">\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0430<\/a> \u0432\u043e\u043a\u0440\u0443\u0433 <code>join<\/code>. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u043a\u043e\u043d\u0446\u0435\u043d\u0442, \u0447\u0435\u043c \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u043e\u0435. \u041d\u043e \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0438\u0437\u044f\u0449\u043d\u043e, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 <em>\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e<\/em> \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u043e\u043c. <em>(\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439, \u0438\u043b\u0438 unsafe-\u043a\u043e\u0434 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u2014 \u0432 Rust \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 <code>unsafe {}<\/code>) \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.)<\/em> \u0422\u043e \u0435\u0441\u0442\u044c API \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <code>join<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0435\u0441\u044c \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043a\u043e\u0434. (\u0427\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c, \u0432\u0441\u0451 \u0436\u0435 <em>\u0435\u0441\u0442\u044c<\/em> \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\/collect.rs#L17-L19\">\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e<\/a> \u043f\u0440\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u041d\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0431\u0449\u0435\u0433\u043e \u0441 <em>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u043e\u043c<\/em>, \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Vec<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442.)<br \/>  \u042f \u043d\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0433\u0440\u0443\u0436\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u0438\u043b\u044c\u043d\u043e \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e \u043c\u043e\u0438\u043c \u043f\u043b\u0430\u043d\u0430\u043c \u043e\u043d \u0435\u0449\u0451 \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. \u041d\u043e \u043d\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0438\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0442\u0438\u043f\u0430\u0436 <code>ParallelIterator<\/code> <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\/mod.rs#L30-L35\">\u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438<\/a>:<\/p>\n<pre><code class=\"rust\">pub trait ParallelIterator {     type Item;     type Shared: Sync;     type State: ParallelIteratorState&lt;Shared=Self::Shared, Item=Self::Item&gt; + Send;      fn state(self) -&gt; (Self::Shared, Self::State);      ... \/\/ \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0432\u0440\u043e\u0434\u0435 `map` \u0438 \u0442. \u0434. } <\/code><\/pre>\n<p>  \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043e\u0434 <code>state<\/code> \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u043b \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043e\u0431\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <em>\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/em>. \u041e\u0431\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 (\u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e) \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0432\u0441\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0442\u0438\u043f\u0430\u0436\u0443 <code>Sync<\/code> (\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u0438\u0437 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e). \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a <code>join<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u0430\u0436\u0443 <code>Send<\/code> (\u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043b\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443).<br \/>  <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\/mod.rs#L80-L90\">\u0422\u0438\u043f\u0430\u0436<\/a> <code>ParallelIteratorState<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434-\u0441\u0440\u0435\u0437 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438). \u0423 \u043d\u0435\u0433\u043e \u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"rust\">pub trait ParallelIteratorState: Sized {     type Item;     type Shared: Sync;      fn len(&amp;mut self) -&gt; ParallelLen;      fn split_at(self, index: usize) -&gt; (Self, Self);      fn for_each&lt;OP&gt;(self, shared: &amp;Self::Shared, op: OP)         where OP: FnMut(Self::Item); } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>len<\/code> \u0434\u0430\u0451\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u0442\u0430\u0432\u0448\u0435\u0439\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u044b. \u041c\u0435\u0442\u043e\u0434 <code>split_at<\/code> \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u0442 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438. \u041c\u0435\u0442\u043e\u0434 <code>for_each<\/code> \u0432\u044b\u0434\u0430\u0451\u0442 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u0422\u0430\u043a \u0447\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u0440\u0435\u0437\u0430 <code>&amp;[T]<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442:  <\/p>\n<ul>\n<li>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>len<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0451\u0442 \u0434\u043b\u0438\u043d\u0443 \u0441\u0440\u0435\u0437\u0430,<\/li>\n<li>\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>split_at<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442 \u0441\u0440\u0435\u0437 \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0434-\u0441\u0440\u0435\u0437\u0430,<\/li>\n<li>\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <code>for_each<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0451\u0442\u0441\u044f \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e <code>op<\/code>.<\/li>\n<\/ul>\n<p>  \u0418\u043c\u0435\u044f \u043e\u0431\u0430 \u044d\u0442\u0438\u0445 \u0442\u0438\u043f\u0430\u0436\u0430, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0441\u043b\u0435\u0434\u0443\u044f \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0443. \u041c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u044b, \u0435\u0441\u043b\u0438 \u0435\u0451 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e, \u0442\u043e \u0434\u0435\u043b\u0438\u043c \u0435\u0451 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438. \u0418\u043d\u0430\u0447\u0435 \u043c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e (\u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435):<\/p>\n<pre><code class=\"rust\">fn process(shared, state) {     if state.len() is too big {         \/\/ \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438         let midpoint = state.len() \/ 2;         let (state1, state2) = state.split_at(midpoint);         rayon::join(|| process(shared, state1),                     || process(shared, state2));     } else {         \/\/ \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f         state.for_each(|item| {             \/\/ process item         })     } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0438, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043b\u044f <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\/collect.rs#L17-L19\">\u0441\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440<\/a> \u0438 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/src\/par_iter\/reduce.rs#L20-L42\">\u0441\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/a>.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043f\u0440\u0430\u0432\u043a\u0430<\/h3>\n<p>  \u042f \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Rayon. \u041e\u043d\u0430 \u0436\u0443\u0442\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f, \u0438 \u044f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0443 \u043d\u0435\u0451 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b \u0441\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439.<br \/>  \u0410 \u0435\u0449\u0451, \u043e\u0447\u0435\u043d\u044c \u043e\u0442\u0440\u0430\u0434\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c \u0441\u0442\u0430\u043b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rust. \u042d\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0433\u043e\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0441\u0432\u043e\u0438\u0445 \u0440\u0430\u043d\u043d\u0438\u0445 \u0434\u043d\u044f\u0445 Rust, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u0442\u0440\u043e\u0433\u0438\u0439, \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043d\u0430 Erlang \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b\u044b, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0449\u0435\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u043e \u043d\u0435 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 quicksort. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0438\u043f\u043e\u0432, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u043b\u0438\u0441\u044c \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 quicksort.<br \/>  \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043c\u043e\u0438 <a href=\"http:\/\/smallcultfollowing.com\/babysteps\/blog\/2013\/06\/11\/data-parallelism-in-rust\/\">\u0440\u0430\u043d\u043d\u0438\u0435<\/a> <a href=\"http:\/\/smallcultfollowing.com\/babysteps\/blog\/2012\/06\/11\/hotpar\/\">\u0434\u0438\u0437\u0430\u0439\u043d\u044b<\/a>, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f <code>Rayon<\/code> \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043b\u0443\u0447\u0448\u0430\u044f. \u0427\u0442\u043e \u043c\u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u0442\u0430\u043a \u044d\u0442\u043e \u0447\u0442\u043e \u043e\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043d\u043e \u0438 \u0434\u043b\u044f <em>\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432<\/em> \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0443\u043c\u0430\u0441\u0448\u0435\u0434\u0448\u0438\u0435 \u0442\u0440\u044e\u043a\u0438 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0442\u0438\u043f\u043e\u0432 Rust \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u043e\u043b\u043e\u043c\u043d\u044b\u0435 \u0442\u0438\u043f\u0430\u0436\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0432\u0443\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c:  <\/p>\n<ul>\n<li><em><a href=\"http:\/\/smallcultfollowing.com\/babysteps\/blog\/2012\/11\/18\/imagine-never-hearing-the-phrase-aliasable\/\">\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u043e \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b<\/a><\/em>. \u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u043e, \u0447\u0442\u043e \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 <code>&amp;mut<\/code> \u043d\u0435\u043b\u044c\u0437\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b, \u0438 \u0443\u0431\u0440\u0430\u043b\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0435 <code>const<\/code>-\u0441\u0441\u044b\u043b\u043a\u0438 (\u0441\u0441\u044b\u043b\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435) <em>(\u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 Rust \u043d\u0435\u0442 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432\u0441\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u043d\u0438\u044e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <code>const<\/code> \u043d\u0435\u0442, \u043f\u0440\u043e \u0442\u043e \u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u2014 \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.)<\/em>. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0440\u044b Rust \u0441\u0442\u0435\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, <em>\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/em> \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043e\u0442 \u0433\u043e\u043d\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li><a href=\"https:\/\/github.com\/rust-lang\/rfcs\/blob\/master\/text\/0458-send-improvements.md\">\u0423\u043b\u0443\u0447\u0449\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f\u0430\u0436 Send<\/a>, RFC458. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e \u0442\u0438\u043f\u0430\u0436 <code>Send<\/code> \u0442\u0430\u043a, \u0447\u0442\u043e \u043e\u043d \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u0438\u043c\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438. \u0414\u043e \u044d\u0442\u043e\u0433\u043e RFC \u0437\u0430 \u0430\u0432\u0442\u043e\u0440\u0441\u0442\u0432\u043e\u043c <a href=\"https:\/\/github.com\/pythonesque\">\u0414\u0436\u043e\u0448\u0443\u0430 \u042f\u043d\u043a\u043e\u0432\u0441\u043a\u043e\u0433\u043e<\/a> \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <code>Send<\/code>-\u0434\u0430\u043d\u043d\u044b\u0435: \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0431\u044b\u0442\u044c <code>'static<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0442\u0435\u043a. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u0438\u0435\u043c \u0432\u043b\u0438\u044f\u043d\u0438\u044f Erlang, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0431\u044b\u043b\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c\u0438 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438, \u043d\u043e \u043d\u0438\u043a\u0442\u043e \u0438\u0437 \u043d\u0430\u0441 \u043d\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043b \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0436\u0443\u0442\u043a\u043e \u043a\u043e\u0440\u0451\u0436\u0438\u0442\u044c \u043c\u043e\u0438 \u0440\u0430\u043d\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u0430\u0436\u0438 \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u0438 \u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0441\u0442\u0435\u043a.<br \/>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0414\u0436\u043e\u0448\u0443\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 <code>'static<\/code> \u0441 \u0442\u0438\u043f\u0430\u0436\u0430 <code>Send<\/code>, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u0441\u0442\u0430\u043b\u043e \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435!<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435: \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430<\/h3>\n<p>  \u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u0443\u0447\u0448\u0435\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 quicksort, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434, \u0435\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b. \u0411\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 quicksort \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u0430\u0436\u0438 Rust \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0432\u0443\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043a\u043e\u0434\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/blob\/22f04aee0e12b31e029ec669299802d6e2f86bf6\/demo\/quicksort\/src\/main.rs#L47-L60\">\u0442\u0440\u044e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435<\/a>.<br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u0430\u0436 <code>Joiner<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>join<\/code>:<\/p>\n<pre><code class=\"rust\">trait Joiner {     \/\/\/ \u0418\u0441\u0442\u0438\u043d\u0430 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430, \u043b\u043e\u0436\u044c \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.     fn is_parallel() -&gt; bool;      \/\/\/ \u041b\u0438\u0431\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 `rayon::join`, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0441\u0442\u043e `oper_a(); oper_b();`.     fn join&lt;A,R_A,B,R_B&gt;(oper_a: A, oper_b: B) -&gt; (R_A, R_B)         where A: FnOnce() -&gt; R_A + Send, B: FnOnce() -&gt; R_B + Send; } <\/code><\/pre>\n<p>  \u0423 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430\u0436\u0430 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0435\u0436\u0438\u043c\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"rust\">struct Parallel; impl Joiner for Parallel { .. }  struct Sequential; impl Joiner for Sequential { .. } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c <code>quick_sort<\/code> \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0438\u043f\u0430 <code>J: Joiner<\/code>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e (\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e). \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043b\u044f \u043c\u0430\u043b\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e:<\/p>\n<pre><code class=\"rust\">fn quick_sort&lt;J:Joiner, T:PartialOrd+Send&gt;(v: &amp;mut [T]) { if v.len() &gt; 1 {     \/\/ \u041e\u0442\u043a\u0430\u0442 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043e\u0440\u043e\u0447\u0435 5K:     if J::is_parallel() &amp;&amp; v.len() &lt;= 5*1024 {     return quick_sort::&lt;Sequential, T&gt;(v);     }      let mid = partition(v);     let (lo, hi) = v.split_at_mut(mid);     J::join(|| quick_sort::&lt;J,T&gt;(lo),             || quick_sort::&lt;J,T&gt;(hi)); } <\/code><\/pre>\n<div class=\"clear\"><\/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\/post\/274299\/\"> http:\/\/habrahabr.ru\/post\/274299\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043f\u0430\u0440\u0443 \u043d\u0435\u0434\u0435\u043b\u044c \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/nikomatsakis\/rayon\/\">Rayon<\/a> \u2014 \u043c\u043e\u0435\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f <strong>\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong> \u0432 Rust.<br \/>  \u042f \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0432\u043e\u043b\u0435\u043d \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0434\u0451\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043a \u0447\u0435\u043c\u0443 \u044f \u043f\u0440\u0438\u0448\u0451\u043b \u0432 \u0431\u043b\u043e\u0433 \u043f\u043e\u0441\u0442\u0435.<br \/>  <strong>\u0426\u0435\u043b\u044c Rayon \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u044b\u043c,<\/strong> \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u043a\u043b <code>for<\/code> \u0438\u043b\u0438 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432:<\/p>\n<pre><code class=\"rust\">let total_price = stores.iter()                         .map(|store| store.compute_price(&amp;list))                         .sum() <\/code><\/pre>\n<p>  \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0451 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <em>\u00ab\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u00bb<\/em> \u043d\u0430 <em>\u00ab\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u00bb<\/em> \u0438\u0437 Rayon:<\/p>\n<pre><code class=\"rust\">let total_price = stores.par_iter()                         .map(|store| store.compute_price(&amp;list))                         .sum() <\/code><\/pre>\n<p>  <\/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-271374","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271374","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=271374"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271374\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=271374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=271374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=271374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}