Go Channels in Ruby
- by Julius Eckert
In the Go programming language, you can send Messages around using a construct called "Channels".
http://golang.org/doc/effective_go.html#channels
I would love to use something like that in Ruby, especially for IPC.
Pseudocode of what I want:
channel = Channel.new
fork do
3.times{ channel.send("foo ") }
exit!
end
Thread.new do
3.times{ channel.send("bar ") }
end
loop do
print channel.recv
end
# ~> bar foo foo bar bar foo
Is there any construct, library or equivalent for Ruby which works like that ?
If not: What is the best way to build such an abstraction?