Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- Here is output:
- > ruby ractor_play.rb
- ractor_play.rb:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
- 11
- 1
- 12
- 2
- 13
- 3
- 14
- 4
- 5
- 15
- 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement