{"id":277141,"date":"2016-03-29T02:26:03","date_gmt":"2016-03-28T22:26:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=277141"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=277141","title":{"rendered":"man!( Go =&gt; D ).concurrency"},"content":{"rendered":"<p>       \u041c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 Go \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. \u041f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441 \u0442\u0435\u0440\u043f\u043a\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0432\u043a\u0443\u0441\u0438\u0435\u043c, \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438 \u043c\u043e\u0449\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438, \u043f\u043e\u0434\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0432\u043e\u0438\u043c \u0438\u0437\u044f\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438. \u0410 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043b\u0443\u0447\u0448\u0435\u0435, \u0443\u0436\u0435 \u0442\u0430\u043a \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a, \u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u0435\u043d \u0438 \u0441 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0442\u043e\u043b\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u043d\u0430\u0438\u0433\u0440\u0430\u043b\u0438\u0441\u044c \u0441 Go, \u0443\u0441\u0442\u0430\u043b\u0438 \u043e\u0442 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u044b, \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0436\u043e\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430\u043c\u0438 \u0438 \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u043f\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0435 \u043e \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0438 <a href=\"https:\/\/blog.golang.org\/generate\">\u043f\u0440\u043e\u0442\u0435\u0437\u043e\u0432 \u0434\u043b\u044f \u0440\u0443\u043a<\/a>, \u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/tour.golang.org\/list\">Tour of the Go<\/a> c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0430 <a href=\"http:\/\/dlang.org\/\">D<\/a> \u0438 \u043a\u0440\u0430\u0442\u043a\u0438\u043c\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c \u043f\u044f\u0442\u0430\u044f. \u0421\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/h1>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>Coroutines<\/h2>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/1\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import (     &quot;fmt&quot;     &quot;time&quot; )  func say(s string) {     for i := 0; i &lt; 5; i++ {         time.Sleep(100 * time.Millisecond)         fmt.Println(s)     } }  func main() {     go say(&quot;world&quot;)     say(&quot;hello&quot;) }<\/code><\/pre>\n<p>  Go \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443, \u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c \u0435\u0451 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f. \u0412\u0441\u0435 \u0433\u043e\u043f\u043e\u0442\u043e\u043a\u0438 (\u0432\u043e\u043b\u043e\u043a\u043d\u0430, fibers, \u0441\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, coroutines, greenlets) \u0432\u044b\u043f\u043e\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u043d\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043d\u0438\u0442\u044f\u0445, threads), \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (cores). \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 D <a href=\"http:\/\/dlang.org\/phobos\/core_thread.html#.Fiber\">\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u043b\u043e\u043a\u043d\u0430<\/a>, \u043d\u043e \u043b\u0438\u0448\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u043d\u0438\u0442\u0438 \u0438 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u043b\u043e\u043a\u043d\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0438\u0442\u0435\u0439. \u041d\u043e <a href=\"http:\/\/vibed.org\/api\/vibe.core.core\/runWorkerTaskH\">\u0442\u0430\u043a\u043e\u0439 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 vibe.d<\/a>, \u043f\u0440\u0430\u0432\u0434\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u0435\u043d \u043a\u0430\u043a \u0432 Go. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/github.com\/nin-jin\/go.d\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 go.d<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435\u0439 \u0448\u0430\u0431\u043b\u043e\u043d &quot;go!&quot; \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u043b\u0435\u0434\u0443\u044f \u043b\u0443\u0447\u0448\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u043c, \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import core.time;     import std.range;     import jin.go;      __gshared static string[] log;      static void saying( string message )     {         foreach( _ ; 3.iota ) {             sleep( 100.msecs );             log ~= message;         }     }      go!saying( &quot;hello&quot; );     sleep( 50.msecs );     saying( &quot;world&quot; );      log.assertEq([ &quot;hello&quot; , &quot;world&quot; , &quot;hello&quot; , &quot;world&quot; , &quot;hello&quot; , &quot;world&quot; ]); }<\/code><\/pre>\n<p>  \u0412 D \u043d\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0438\u0442\u044c \u0431\u0435\u0437 \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0446\u0438\u043a\u043b \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0424\u0443\u043d\u043a\u0446\u0438\u044e &quot;saying&quot; \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043d\u0435 \u0438\u043c\u0435\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0435\u0451 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0438\u0442\u044f\u0445. \u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u0435\u043c, \u0443\u0431\u0440\u0430\u0432 &quot;static&quot;, \u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u2014 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442 \u043d\u0430\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0438\u0441\u0442\u043e\u043b\u0435\u0442 \u0432 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438. \u0412 Go \u0436\u0435 \u0432\u043e\u043f\u0440\u043e\u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0435\u0451 \u043d\u0435\u0442. <\/p>\n<h1>Buffered Channels<\/h1>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/3\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code>package main  import &quot;fmt&quot;  func main() {     ch := make(chan int, 2)     ch &lt;- 1     ch &lt;- 2     fmt.Println(&lt;-ch)     fmt.Println(&lt;-ch) }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435 \u0442\u0430\u043a \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0445 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438. Go \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u2014 \u043a\u0430\u043d\u0430\u043b\u044b. \u041a\u0430\u043d\u0430\u043b\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043a \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0438\u0437 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0442\u043e \u043e\u043d \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0443\u0434\u0430 \u0437\u0430\u043f\u0438\u0448\u0435\u0442. \u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b, \u0442\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u0430 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u041a\u0430\u043d\u0430\u043b\u044b \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u043b\u0435\u043d\u0438\u0432\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043e\u0431\u0435\u0449\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u0432\u043d\u043e\u0441\u044f \u0441 \u0441\u043e\u0431\u043e\u0439 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 D \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/dlang.org\/library\/std\/concurrency\/receive.html\">\u043f\u0440\u0438\u0451\u043c\/\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/a>. \u0422\u043e \u0435\u0441\u0442\u044c, \u0437\u043d\u0430\u044f id \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0430 \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a-\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c. Vibe.d \u0432\u0432\u043e\u0434\u0438\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e <a href=\"http:\/\/vibed.org\/api\/vibe.core.stream\/\">\u043f\u043e\u0442\u043e\u043a\u0430 \u0431\u0430\u0439\u0442<\/a> \u0441 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0433\u043e\u043a\u0430\u043d\u0430\u043b\u0430\u043c. \u041d\u043e \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0430\u0439\u0442\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c, \u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 Go, \u0447\u0442\u043e \u0432 D, \u043c\u0435\u0436\u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0430\u044f \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0445\u0432\u0430\u0442 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430, \u0447\u0442\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9D%D0%B5%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D1%83%D1%8E%D1%89%D0%B0%D1%8F_%D1%81%D0%B8%D0%BD%D1%85%D1%80%D0%BE%D0%BD%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F\">\u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0431\u0435\u0437\u044b\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u043f\u044f\u0442\u044c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 go.d, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u043d\u0430\u043c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 wait-free \u043a\u0430\u043d\u0430\u043b\u044b.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import jin.go;      auto numbers = new Channel!int(2);     numbers.next = 1;     numbers.next = 2;     numbers.next.assertEq( 1 );     numbers.next.assertEq( 2 ); }<\/code><\/pre>\n<p>  \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e &quot;next&quot;, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e, \u043a\u0430\u043a \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043a\u0430 \u0432 Go, \u0437\u0430\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0438\u0441\u0442\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0438\u0441\u0442\u043e\u043b\u0435\u0442\u0430, \u0438 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b \u0442\u0438\u043f\u044b, \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043d\u0438\u0442\u0435\u0439. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u044d\u0442\u0438 \u043a\u0430\u043d\u0430\u043b\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0438\u0445 \u0431\u044b\u043b\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u043e\u043a\u0430 \u0437\u0430 \u044d\u0442\u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0438 \u0442\u0443\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u0432 \u043d\u0430\u0448\u0438 \u0441\u043e\u044e\u0437\u043d\u0438\u043a\u0438. <br \/>  \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u0430\u043d\u0430\u043b\u0430 \u0432 Go \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0440\u0430\u0432\u0435\u043d \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443, \u0430 \u0432 go.d \u043e\u043a\u043e\u043b\u043e 512 \u0431\u0430\u0439\u0442.<\/p>\n<h1>Channels<\/h1>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/2\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import &quot;fmt&quot;  func sum(s []int, c chan int) {     sum := 0     for _, v := range s {         sum += v     }     c &lt;- sum \/\/ send sum to c }  func main() {     s := []int{7, 2, 8, -9, 4, 0}      c := make(chan int)     go sum(s[:len(s)\/2], c)     go sum(s[len(s)\/2:], c)     x, y := &lt;-c, &lt;-c \/\/ receive from c      fmt.Println(x, y, x+y) \/\/ -5 17 12 }<\/code><\/pre>\n<p>  \u0412 Go \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0430\u043d\u0430\u043b\u043e\u043c \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u0430 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u043c, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u043d\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435. \u041a\u0430\u043d\u0430\u043b\u044b \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 go.d, \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u043d\u0435\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b-\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 Inputs \u0438 Outputs. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f Inputs, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0435\u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432 \u043d\u0435\u0439.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import std.algorithm;     import std.range;     import jin.go;      static auto summing( Channel!int sums , const int[] numbers ) {         sums.next = numbers.sum;     }      immutable int[] numbers = [ 7 , 2 , 8 , -9 , 4 , 0 ];      Inputs!int sums;     go!summing( sums.make(1) , numbers[ 0 .. $\/2 ] );     go!summing( sums.make(1) , numbers[ $\/2 .. $ ] );     auto res = sums.take(2).array;      ( res ~ res.sum ).assertEq([ 17 , -5 , 12 ]); }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043c\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u043c \u0440\u0443\u043a\u0430\u043c\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c &quot;sum&quot;. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u0432\u0430\u0448\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 <a href=\"http:\/\/dlang.org\/phobos\/std_range_interfaces.html\">\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u0430\u043a \u0432 Channel, \u0442\u0430\u043a \u0438 \u0432 Inputs, \u0438 \u0432 Outputs. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c &quot;take&quot; \u0432\u044b\u0434\u0430\u0451\u0442 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430. \u0410 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c &quot;array&quot; \u0432\u044b\u0433\u0440\u0435\u0431\u0430\u0435\u0442 \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043d\u0438\u043c\u0438. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u043d\u044b \u0438 \u0441\u0440\u0435\u0437 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043f\u0440\u0438\u0432\u0435\u0442, \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c!).<\/p>\n<h1>Range and Close<\/h1>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/4\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import (     &quot;fmt&quot; )  func fibonacci(n int, c chan int) {     x, y := 0, 1     for i := 0; i &lt; n; i++ {         c &lt;- x         x, y = y, x+y     }     close(c) }  func main() {     c := make(chan int, 10)     go fibonacci(cap(c), c)     for i := range c {         fmt.Println(i)     } }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 Go \u043c\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043a\u0430\u043d\u0430\u043b\u0443, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0438\u0437 \u043d\u0435\u0433\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u043d\u0443\u0442\u044c \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043d\u0430\u043b\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u043c\u043e\u0433\u043b\u0430 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0446\u0438\u043a\u043b \u043f\u043e\u0440\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c. \u0412 D \u043c\u044b \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0431\u044b \u0440\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u044b.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import std.range;     import jin.go;      static auto fibonacci( Channel!int numbers , int count )     {         auto range = recurrence!q{ a[n-1] + a[n-2] }( 0 , 1 ).take( count );         foreach( x ; range ) numbers.next = x;         numbers.close();     }      auto numbers = new Channel!int(10);     go!fibonacci( numbers , numbers.size );      numbers.array.assertEq([ 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 ]); }<\/code><\/pre>\n<p>  \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0451 \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434, \u0437\u043d\u0430\u044f, \u0447\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d &quot;go!&quot; \u0441\u0430\u043c \u0443\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432 \u043a\u0430\u043d\u0430\u043b. <\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import std.range;     import jin.go;      static auto fibonacci( int limit )     {         return recurrence!q{ a[n-1] + a[n-2] }( 0 , 1 ).take( limit );     }      fibonacci( 10 ).array.assertEq([ 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 ]);     go!fibonacci( 10 ).array.assertEq([ 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 ]); }<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u0440\u043e \u043a\u0430\u043d\u0430\u043b\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0451 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u0430 \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0436\u0438\u0434\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0435\u0451 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<h1>Select<\/h1>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/5\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import &quot;fmt&quot;  func fibonacci(c, quit chan int) {     x, y := 0, 1     for {         select {         case c &lt;- x:             x, y = y, x+y         case &lt;-quit:             fmt.Println(&quot;quit&quot;)             return         }     } }  func main() {     c := make(chan int)     quit := make(chan int)     go func() {         for i := 0; i &lt; 10; i++ {             fmt.Println(&lt;-c)         }         quit &lt;- 0     }()     fibonacci(c, quit) }<\/code><\/pre>\n<p>  Go \u0438\u043c\u0435\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438. D \u043d\u0438\u0447\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. \u041e\u0434\u043d\u0430\u043a\u043e, \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0446\u0438\u043a\u043b\u0430 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import std.range;     import jin.go;      __gshared int[] log;      static auto fibonacci( Channel!int numbers , Channel!bool control )     {         auto range = recurrence!q{ a[n-1] + a[n-2] }( 0 , 1 );          while( !control.closed )         {             if( numbers.needed ) numbers.next = range.next;             yield;         }          log ~= -1;         numbers.close();     }      static void print( Channel!bool control , Channel!int numbers )     {         foreach( i ; 10.iota ) log ~= numbers.next;         control.close();     }      auto numbers = new Channel!int(1);     auto control = new Channel!bool(1);      go!print( control , numbers );     go!fibonacci( numbers , control );      while( !control.empty || !numbers.empty ) yield;      log.assertEq([ 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , -1 ]); }<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f, \u0430 \u0432 \u0446\u0438\u043a\u043b\u0430\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &quot;yield&quot;, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043d\u043a\u0443\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u043b\u043e\u043a\u043d\u0430 \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0432\u0438\u0441\u0438\u0442 \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0438.<\/p>\n<h1>Default Selection<\/h1>\n<p>  <\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/6\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import (     &quot;fmt&quot;     &quot;time&quot; )  func main() {     tick := time.Tick(100 * time.Millisecond)     boom := time.After(500 * time.Millisecond)     for {         select {         case &lt;-tick:             fmt.Println(&quot;tick.&quot;)         case &lt;-boom:             fmt.Println(&quot;BOOM!&quot;)             return         default:             fmt.Println(&quot;    .&quot;)             time.Sleep(50 * time.Millisecond)         }     } }<\/code><\/pre>\n<p>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0432 Go \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e, \u0435\u0441\u043b\u0438 \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043d\u0435 \u0431\u044b\u043b\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. \u0412 D \u0443 \u0432\u0430\u0441, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043d\u0430\u0434 \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import core.time;     import jin.go;      static auto after( Channel!bool channel , Duration dur )     {         sleep( dur );         if( !channel.closed ) channel.next = true;     }      static auto tick( Channel!bool channel , Duration dur )     {         while( !channel.closed ) after( channel , dur );     }      auto ticks = go!tick( 101.msecs );     auto booms = go!after( 501.msecs );      string log;      while( booms.clear )     {         while( !ticks.clear ) {             log ~= &quot;tick&quot;;             ticks.popFront;         }         log ~= &quot;.&quot;;         sleep( 51.msecs );     }     log ~= &quot;BOOM!&quot;;      log.assertEq( &quot;..tick..tick..tick..tick..BOOM!&quot; ); }<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043d\u0430\u043b. \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043d\u0430\u043b \u0438 \u043c\u044b \u0435\u0433\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u043a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 &quot;go!&quot;, \u0447\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u0434\u043e\u0431\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 &quot;after&quot; \u0438 &quot;tick&quot; \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0445 \u0432 \u043e\u0431\u0449\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0443 \u043d\u0438\u0445 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435.<\/p>\n<h1>Mutex<\/h1>\n<p>  \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u0435\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u0441\u0451 \u0436\u0435 \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0442\u0443\u0442 \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<h3><a href=\"https:\/\/tour.golang.org\/concurrency\/9\">Go<\/a><\/h3>\n<p>  <\/p>\n<pre><code class=\"go\">package main  import (     &quot;fmt&quot;     &quot;sync&quot;     &quot;time&quot; )  \/\/ SafeCounter is safe to use concurrently. type SafeCounter struct {     v   map[string]int     mux sync.Mutex }  \/\/ Inc increments the counter for the given key. func (c *SafeCounter) Inc(key string) {     c.mux.Lock()     \/\/ Lock so only one goroutine at a time can access the map c.v.     c.v[key]++     c.mux.Unlock() }  \/\/ Value returns the current value of the counter for the given key. func (c *SafeCounter) Value(key string) int {     c.mux.Lock()     \/\/ Lock so only one goroutine at a time can access the map c.v.     defer c.mux.Unlock()     return c.v[key] }  func main() {     c := SafeCounter{v: make(map[string]int)}     for i := 0; i &lt; 1000; i++ {         go c.Inc(&quot;somekey&quot;)     }      time.Sleep(time.Second)     fmt.Println(c.Value(&quot;somekey&quot;)) }<\/code><\/pre>\n<p>  \u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 Go \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c \u0438 \u0441\u0442\u0440\u0430\u0434\u0430\u043d\u0438\u044f. \u041e\u0434\u043d\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430\u043c\u0438 \u0438 \u0432\u044b \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u0435 \u0443 \u0441\u0435\u0431\u044f <a href=\"http:\/\/vocabulary.ru\/dictionary\/978\/word\/fantomnaja-konechnost\">\u0444\u0430\u043d\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0438<\/a>. \u041d\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u0443\u0436 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430\u043c\u0435\u043a\u043d\u0451\u0442 \u0432\u0430\u043c \u043e \u0442\u043e\u043c, \u0433\u0434\u0435 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b. \u0410 \u0432\u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 D \u0432\u0430\u0441 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0440\u0443\u0433\u0430\u0435\u0442 \u0437\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u044b\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0410 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<h3>D<\/h3>\n<p>  <\/p>\n<pre><code>unittest {     import core.atomic;     import core.time;     import std.range;     import std.typecons;     import jin.go;      synchronized class SafeCounter     {         private int[string] store;          void inc( string key )         {             ++ store[key];         }          auto opIndex( string key )         {             return store[ key ];         }         void opIndexUnary( string op = &quot;++&quot; )( string key )         {             this.inc( key );         }     }      static counter = new shared SafeCounter;      static void working( int i )     {         ++ counter[&quot;somekey&quot;];     }      foreach( i ; 1000.iota ) {         go!working( i );     }      sleep( 1.seconds );      counter[&quot;somekey&quot;].assertEq( 1000 ); }<\/code><\/pre>\n<p>  \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441 \u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u044d\u0442\u043e\u0442 \u043c\u044c\u044e\u0442\u0435\u043a\u0441 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044f\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u0441\u0451 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c. \u041d\u043e \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c (\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0438 \u0434\u043e\u0441\u0430\u0434\u043d\u044b\u0439 \u0431\u0430\u0433 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430): \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, &quot;opIndexUnary!&quot;, \u043d\u0435 \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0445\u0432\u0430\u0442 \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 &quot;inc&quot;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0443\u0436\u0435 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0439, \u0437\u0430\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043a\u0430\u043a \u0440\u043e\u0434\u043d\u043e\u0439. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 &quot;shared SafeCounter&quot; \u043c\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.          \t<\/p>\n<div class=\"polling\">\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u041a\u0430\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"280378\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"14794\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv72308\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72308\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72308\">\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv72310\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72310\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72310\">\u0421\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"checkbox\" id=\"vv72312\" \t\t\t\t\t\tclass=\"checkbox js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72312\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72312\">\u041c\u0435\u0442\u043e\u0434\u044b<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"total\">\u041d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u041d\u0443 \u0447\u0442\u043e, \u043d\u0430 \u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043a\u043b\u0430\u0434\u043d\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"280378\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"14796\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72314\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72314\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72314\">C<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72316\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72316\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72316\">C++<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72318\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72318\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72318\">D<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72320\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72320\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72320\">Go<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72322\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72322\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72322\">Rust<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72324\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72324\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72324\">Java<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72326\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72326\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72326\">C#<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv72328\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"72328\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv72328\">\u0414\u0440\u0443\u0433\u043e\u0439<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"total\">\u041d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<p class=\"for_users_only_msg\">\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a href=\"https:\/\/habrahabr.ru\/auth\/login\/\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/p>\n<\/p><\/div>\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=\"https:\/\/habrahabr.ru\/post\/280378\/\"> https:\/\/habrahabr.ru\/post\/280378\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 Go \u043f\u043e \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. \u041f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441 \u0442\u0435\u0440\u043f\u043a\u0438\u043c \u043f\u043e\u0441\u043b\u0435\u0432\u043a\u0443\u0441\u0438\u0435\u043c, \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438 \u043c\u043e\u0449\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438, \u043f\u043e\u0434\u043a\u0443\u043f\u0430\u044e\u0442 \u0441\u0432\u043e\u0438\u043c \u0438\u0437\u044f\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043c\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u044f\u0437\u044b\u043a\u0430\u043c\u0438. \u0410 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043b\u0443\u0447\u0448\u0435\u0435, \u0443\u0436\u0435 \u0442\u0430\u043a \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a, \u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u0435\u043d \u0438 \u0441 \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0442\u043e\u043b\u043a\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043c\u043d\u043e\u0433\u043e\u0437\u0430\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u043d\u0430\u0438\u0433\u0440\u0430\u043b\u0438\u0441\u044c \u0441 Go, \u0443\u0441\u0442\u0430\u043b\u0438 \u043e\u0442 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u044b, \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0436\u043e\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430\u043c\u0438 \u0438 \u0432\u0441\u0435\u0440\u044c\u0451\u0437 \u043f\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0435 \u043e \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0438 <a href=\"https:\/\/blog.golang.org\/generate\">\u043f\u0440\u043e\u0442\u0435\u0437\u043e\u0432 \u0434\u043b\u044f \u0440\u0443\u043a<\/a>, \u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/tour.golang.org\/list\">Tour of the Go<\/a> c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0430 <a href=\"http:\/\/dlang.org\/\">D<\/a> \u0438 \u043a\u0440\u0430\u0442\u043a\u0438\u043c\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<h1>\u0427\u0430\u0441\u0442\u044c \u043f\u044f\u0442\u0430\u044f. \u0421\u043e\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/h1>\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-277141","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277141","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=277141"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277141\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}