xchannel
xchannel is a library to assist with interprocess communication.
It implements a channel that can be used to transmit ruby objects
between ruby processes running on the same machine. It is implemented
on top of an unbound, streamed unix socket.
Examples
1.
basic fork example.
Marshal is the serializer of choice.
channel = XChannel.unix Marshal
pid = fork do
channel.put Process.pid
channel.put 'Hello!'
end
Process.wait pid
channel.get
channel.get
2.
avoid a blocking read
channel = XChannel.unix Marshal
pid = fork do
sleep 3
channel.put 42
end
until channel.readable?
end
channel.get
Process.wait pid
Install
$ gem install xchannel
Contributing
- Fork it ( https://github.com/rpag/xchannel/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
License
MIT. See LICENSE.txt.