-
Notifications
You must be signed in to change notification settings - Fork 4
Ruby SMP Processing Tool and Non-Blocking Process Mechanism
lp/abundance
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
. . .
/ \ | |
/___\ |.-. . . .--. .-.| .-. .--. .-..-.
/ \ | )| | | |( |( ) | |( (.-'
' `'`-' `--`-' `-`-'`-`-'`-' `-`-'`--'
///////////////////////////////////////////////////////////////////////////////////////
This class provides a mean to parallelize the execution of your program processes.
Based on the low maintenance Gardener,Garden,Seed natural design pattern.
Its for:
* running otherwise blocking loops in a non-blocking fashion
* a simple abstraction for loopback communication with a forked execution
* concurrent batch processing
* scaling process intensive computations for SMP execution
And not:
* a replacement for Thread.new invocations
* a replacement for concurrent programming languages like Erlang
Its initial implementation uses:
* pure ruby
* standard forks as mean to parallel non-blocking execution
* fast loopback sockets for process fork communication.
* serialization friendly communication with process forks
* a tier queuing fork, as a packet control middle man between process forks and the non-blocking process client
* an elemental namespace: a process queue, named the Garden, with concurrent workers, named Rows, all this getting orchestrated by a Gardener.
///////////////////////////////////////////////////////////////////////////////////////
Quick Start:
1. gem install abundance
2. require abundance
3. use the Abundance.gardener method to define your forking process. Its attached block IS THE FORK. Its return value IS YOUR CLIENT INSTANCE.
4. Abundance.gardener has simple commodities:
* infinite loop inside Abundance.grow method's block
* initialisation before Abundance.grow invocation, just put it there... you can use Abundance.init_status if you need init confirmation from the forks, otherwise don't bother.
* reader and sender for socket communication with your client. seed.sprout reads, seed.crop sends.
5. use the client to communicate with forks: client.seed sends, client.harvest reads.
6. for detailed client docs: http://abundance.rubyforge.org/ruby-doc/classes/Gardener.html , and full docs: http://abundance.rubyforge.org/ruby-doc/
///////////////////////////////////////////////////////////////////////////////////////
Example:
gardener = Abundance.gardener( :wheelbarrow => 124, :rows => 2, :init_timeout => 2) do
processor = SpecialProcess.new
if processor.started_successfully?
Abundance.init_status(true, processor.init_message)
else
Abundance.init_status(false, processor.init_message)
end
Abundance.grow do |seed|
command = seed.sprout
results = processor.parse(command)
seed.crop( true, results)
end
end
id1 = gardener.seed('command1')
id2 = gardener.seed('command2')
result1 = gardener.harvest(:one,id1)
result2 = gardener.harvest(:one,id2)
# with many more seeds over here
gardener.close
///////////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2008 Louis-Philippe Perron
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
About
Ruby SMP Processing Tool and Non-Blocking Process Mechanism
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published