Last active
July 21, 2021 12:10
-
-
Save DRVTiny/73753beb3104722d450a5868198f1e2a 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
def log(msg) | |
puts "#{Fiber.current.name}: #{msg}" | |
end | |
def maybe_inf_op | |
Channel(Int32).new.tap do |fin_ch| | |
spawn do | |
loop do | |
s = "aaa" * rand(10) | |
end | |
fin_ch.send(777) | |
end | |
end | |
end | |
select | |
when maybe_inf_op.receive | |
log "Ooohoo!" | |
when timeout 3.seconds | |
log "timeout :(" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment