Skip to content

Instantly share code, notes, and snippets.

@Hexa
Last active April 26, 2016 15:49
Show Gist options
  • Save Hexa/2b0e76fb7d94b59224a0a442d6b560e0 to your computer and use it in GitHub Desktop.
Save Hexa/2b0e76fb7d94b59224a0a442d6b560e0 to your computer and use it in GitHub Desktop.
channel
j = 0
SIZE = 10000
a = Deque(Int32).new(SIZE)
#a = [] of Int32
in_channel = Channel(String).new
out_channel = Channel(String).new
spawn do
loop do
receive = in_channel.receive
puts "in: #{receive}"
spawn do
a << j
j += 1
out_channel.send("out: #{receive}")
end
end
end
SIZE.times do |i|
spawn do
in_channel.send("msg-#{i}")
end
end
SIZE.times do
puts out_channel.receive
end
puts j
puts a.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment