You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AFAIK, we even never mention any example/document for select in crystal book or API or official blog.
I consider following examples probably is a good start which i discuss with @Blacksmoke16 on here
ch =Channel(Int32).new
terminate =Channel(Nil).new
done =Channel(Nil).new
[1, 2, 3].each do |i|
spawndo
ch.send i
endendspawndoloopdoselectwhen value = ch.receive
p value
when terminate.receive?
breakendend
done.close
end
terminate.close
done.receive?
ch =Channel(Int32).new
[1, 2, 3].each do |i|
spawndo# => NOTICE: spawn 3 fiber here.
ch.send i
endendloopdobreakif ch.closed?
selectwhen value = ch.receive?
p value
when timeout 3.seconds
puts"Timeout"
ch.close
endend
The text was updated successfully, but these errors were encountered:
e.g. https://lbarasti.com/post/select_statement/, i thought we should add it into official blog.
AFAIK, we even never mention any example/document for
select
in crystal book or API or official blog.I consider following examples probably is a good start which i discuss with @Blacksmoke16 on here
The text was updated successfully, but these errors were encountered: