This commit is contained in:
Loic Nageleisen 2015-08-03 13:50:05 +02:00
parent 1921f98e47
commit 5a968ac76c
11 changed files with 219 additions and 0 deletions

15
examples/many_to_one.rb Normal file
View file

@ -0,0 +1,15 @@
# http://stackoverflow.com/questions/15715605/multiple-goroutines-listening-on-one-channel
require 'channel'
c = Channel.new
1.upto(5) do |i|
go(lambda { |i, co|
1.upto(5) do |j|
co << format("hi from %d.%d", i, j)
end
}, i, c)
end
25.times { puts c.recv }