Created
August 25, 2023 12:50
-
-
Save xvalen/0f18353c3721a1eb963f5d9ce5a5c73f to your computer and use it in GitHub Desktop.
loop is stopped after r2 is complete and r1 is not finished
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r1 = Ractor.new do | |
1.upto(10) do |i| | |
sleep(0.2) | |
Ractor.yield i | |
end | |
end | |
r2 = Ractor.new do | |
11.upto(15) do |i| | |
sleep(0.2) | |
Ractor.yield i | |
end | |
end | |
loop do | |
_, obj = Ractor.select(r1, r2) | |
puts obj | |
end |
adam12
commented
Aug 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment