{"blog_url":"https://secret-garden.hatenablog.com/","version":"1.0","title":"Ruby \u306e Ractor \u3067 sleep sort \u3092\u3084\u3063\u3066\u307f\u305f","image_url":null,"width":"100%","type":"rich","provider_url":"https://hatena.blog","author_url":"https://blog.hatena.ne.jp/osyo-manga/","categories":["Ruby 3.0","Ruby"],"author_name":"osyo-manga","description":"\u7c21\u5358\u306b\u3084\u3063\u3066\u307f\u305f\u3002 $stdout.sync = true puts \"\u304b\u3044\u3057\uff01\uff01\uff01\" data = (1..10).to_a.shuffle pp data ractors = data.map { |i| Ractor.new(i) { |it| # \u30d0\u30c3\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7121\u52b9\u5316 $stdout.sync = true sleep it / 5.0 puts it } } # \u5f85\u3061\u51e6\u7406 ractors.map(&:take) puts \"\u304a\u308f\u308a\uff01\uff01\" https://wandbox.org/permlink/8uwLgJDQ1eP4dDKa \u30b3\u30fc\u30c9\u81ea\u4f53\u306f\u305d\u3093\u306a\u306b\u96e3\u3057\u3044\u3053\u3068\u306f\u3084\u3063\u3066\u3044\u307e\u305b\u3093\u306d\u3002","published":"2020-09-19 11:55:11","height":"190","blog_title":"Secret Garden(Instrumental)","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsecret-garden.hatenablog.com%2Fentry%2F2020%2F09%2F19%2F115511\" title=\"Ruby \u306e Ractor \u3067 sleep sort \u3092\u3084\u3063\u3066\u307f\u305f - Secret Garden(Instrumental)\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","url":"https://secret-garden.hatenablog.com/entry/2020/09/19/115511"}