Skip to content

Instantly share code, notes, and snippets.

@DRVTiny
Last active July 21, 2021 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DRVTiny/73753beb3104722d450a5868198f1e2a to your computer and use it in GitHub Desktop.
Save DRVTiny/73753beb3104722d450a5868198f1e2a to your computer and use it in GitHub Desktop.
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