Currently, the example in the docs for ::spawn still uses the old way of handling fibers that return nil, namely:
# Write "1" every 1 second and "2" every 2 seconds for 6 seconds.
ch = Channel(Nil).new
spawn do
6.times do
sleep 1.second
puts 1
end
ch.send(nil)
end
spawn do
3.times do
sleep 2.seconds
puts 2
end
ch.send(nil)
end
2.times { ch.receive }
This PR aims to modernise the example using WaitGroup.
Currently, the example in the docs for
::spawn
still uses the old way of handling fibers that returnnil
, namely:This PR aims to modernise the example using
WaitGroup
.