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 like to use something similar in Ruby, especially for IPC.
Pseudo-code 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
Is there any constructor, library, or Ruby equivalent that works like this?
If not: what is the way to build such an abstraction?
UPDATE: To clarify what I need from these channels.
One use case: some branched workers are waiting for jobs. They all read from the same JobChannel and output the results to the same ResultChannel.
The channels I need
- very fast
- records are not blocked (message sending)
- reads a block, (receiving a message)
- ,
- .
- DRb ( + + )
- (UNIXSocket, TCPSocket... , , . UNIXSockets. , , ?)
- . ( )
- , .., .