OVERVIEW
Project | IProcess |
---|---|
Homepage | https://github.com/robgleeson/IProcess |
Documentation | http://rubydoc.info/gems/iprocess/frames |
CI | |
Author | Rob Gleeson |
DESCRIPTION
Provides a number of abstractions on top of spawning subprocesses and interprocess communication. The API is simple and can be easily used to spawn multiple subprocesses that can return Ruby objects back to the parent process. Ruby objects are serialized before being sent between processes, and you have the option to choose what serializer to use.The default is the Marshal module.
EXAMPLES
1.
A demo of how to spawn two subprocesses.
= IProcess.spawn(2) { {msg: "hello"} }
p # => [{msg: "hello"}, {msg: "hello"}]
2.
You can spawn a subprocess with a block or with any object that responds to
call
. If you had a block that had become too complicated you could try
refactoring it into a class:
class Unit
def initialize
@num = 1
end
def call
@num += 1
end
end
IProcess.spawn 3, Unit.new # => [2,2,2]
SERIALIZERS
A serializer is any object that implements load & dump.
You can choose what serializer you'd like to use through
the IProcess.serializer=
method:
IProcess.serializer = JSON
PLATFORM SUPPORT
supported
- CRuby (1.9+)
unsupported
- CRuby 1.8
- MacRuby
- JRuby
- Rubinius (support for Rubinius will come sometime in the future).
INSTALL
$ gem install iprocess
LICENSE
MIT. See LICENSE.txt.