Go channels in Ruby

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

# ~> bar foo foo bar bar foo

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. , , ?)
  • . ( )

- , .., .

+5
4

, , concurrency (goroutines, tasklets, , ). concurrency , .

Python, Stackless; Ruby, Revactor NeverBlock ?

+1
0

Cod IPC .

0
source

All Articles