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:

  • 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 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.
  1. use the client to communicate with forks: client.seed sends, client.harvest reads.
  2. for detailed client docs: , and full docs:
Author:lp (
Copyright:2008 Louis-Philippe Perron - Released under the terms of the MIT license


gardener   grow   init_status  

Public Class methods

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.


  • :wheelbarrow = the socket size for the garden communication packets, in bytes, up to 8192, defaults to 124
  • :rows = garden rows number, the number of concurent threads
  • :init_timeout = allow to pause execution to allow for larger gardens to initialize


 gardener = Abundance.gardener( :wheelbarrow => 124, :rows => 2, :init_timeout => 2) do

  processor =
  if processor.started_successfully?
    Abundance.init_status(true, processor.init_message)
    Abundance.init_status(false, processor.init_message)

  Abundance.grow do |seed|
    command = seed.sprout
    results = processor.parse(command)
    seed.crop( true, results)


 id1 = gardener.seed('command1')
 id2 = gardener.seed('command2')

 result1 = gardener.harvest(:one,id1)
 result2 = gardener.harvest(:one,id2)

 # with many more seeds over here


The grow class method needs to be used inside the gardener invocation. A seed instance is given each time, acting as getter/setter for your queued seed commands

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.


  • success = success of the initialisation, may be true or false
  • message = a ruby expression or object


  Abundance.init_status(true,'Initialisation Successfull!!!')