AK
Size: a a a
AK
AK
AK
c = 0
ch_sync = (0..9).map { Channel(Nil).new }
ch_fin = (0..9).map { Channel(Nil).new }
10.times do |ix|
spawn do
ch_sync[9 - ix].receive
1000.times { c += 1 }
ch_fin[ix].send(nil)
end
end
ch_sync.each {|cs| cs.send(nil) }
ch_fin.each {|cf| cf.receive }
puts c
E
E
c = c + 1
AK
E
AK
AK
AK
AK
E
AK
AK
ch = Channel(Int32).new(10)
cf = Channel(Nil).new
10.times do |ix|
spawn do
puts "#{ix} before rcv"
ch.receive
puts "rcvd #{ix}"
cf.send(nil)
end
end
sleep 0.2
10.times do |ix|
puts "sending #{ix}"
ch.send(ix)
Fiber.yield
end
10.times { cf.receive }
AK
AK
E
TF
E
TF