Go Channels in Ruby
Posted
by Julius Eckert
on Stack Overflow
See other posts from Stack Overflow
or by Julius Eckert
Published on 2010-06-17T13:50:51Z
Indexed on
2010/06/17
13:53 UTC
Read the original article
Hit count: 360
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?
© Stack Overflow or respective owner