| Class | Abundance |
| In: |
lib/abundance.rb
|
| Parent: | Object |
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:
And not:
Its initial implementation uses:
///////////////////////////////////////////////////////////////////////////////////////
Quick Start:
| Author: | lp (lp@spiralix.org) |
| Copyright: | 2008 Louis-Philippe Perron - Released under the terms of the MIT license |
The gardener class method initializes a gardener instance with its garden supplied as a block. The invocation block must include the grow class method and a preceeding optional initialisation section that may include and init_status return message.
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
The init_status class method can be used inside the gardener invocation to return an initialisation status message. The returned messages from all garden rows will then be accessible though the gardener‘s init_status instance method.
Abundance.init_status(true,'Initialisation Successfull!!!')