-
-
Save eregon/092ea76534b46e227d9cbf5fd107de66 to your computer and use it in GitHub Desktop.
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
USE_MOVE = !false | |
receive2yield = Ractor.new do | |
loop do | |
if USE_MOVE | |
Ractor.yield Ractor.receive, move: true | |
else | |
Ractor.yield Ractor.receive | |
end | |
end | |
end | |
receive2send = Ractor.new receive2yield do |r| | |
loop do | |
if USE_MOVE | |
r.send Ractor.receive, move: true | |
else | |
r.send Ractor.receive | |
end | |
end | |
end | |
take2yield = Ractor.new receive2yield do |from| | |
loop do | |
if USE_MOVE | |
Ractor.yield from.take, move: true | |
else | |
Ractor.yield from.take | |
end | |
end | |
end | |
take2send = Ractor.new take2yield, Ractor.current do |from, to| | |
loop do | |
if USE_MOVE | |
to.send from.take, move: true | |
else | |
to.send from.take | |
end | |
end | |
end | |
AN = 1_000 | |
LN = 10_000 | |
ary = Array.new(AN) # 1000 | |
# Ractor.make_shareable(ary) | |
LN.times{ | |
receive2send << ary | |
Ractor.receive | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment