forkomatic

Description

Synopsis

class YourForkomaticClass < Forkomatic
  class Job < Forkomatic::Job
    attr_accessor :data

    def initialize(data)
      self.data = data
    end

    def work!
      puts "Working on #{data}"
      sleep 1
    end
  end

  def build_jobs(count)
    (1..count).each.collect {|i| YourForkomaticClass::Job.new(i)}
  end
end

# To just create 20 child processes:
Forkomatic.new(20)

# 10 child processes will be maintained, and the loop will will run twice, waiting 1 second between iterations.
Forkomatic.new({:max_children => 10, :work_interval => 1, :max_iterations => 2})

# The work function will run continuously, adding new child processes as old ones die to maintain a constant 10 processes.
Forkomatic.new({:max_children => 10, :work_interval => 1})

Examples

Contributing to forkomatic

Related projects

forkify: github.com/dakrone/forkify

forkoff: github.com/ahoward/forkoff

Copyright © 2012 Jon Durbin. See LICENSE.txt for further details.