forkomatic 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +50 -2
- data/Rakefile +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,48 @@
|
|
1
1
|
= forkomatic
|
2
2
|
|
3
|
-
|
3
|
+
* http://github.com/gdi/forkomatic
|
4
|
+
|
5
|
+
== Description
|
6
|
+
* forkomatic makes parallel processing extremely simple and powerful.
|
7
|
+
* forkomatic can be used to quickly process data with 'n' processes.
|
8
|
+
* forkomatic can also maintain a set number of processes for any number of iterations, adding new processes as child processes finish.
|
9
|
+
|
10
|
+
== Synopsis
|
11
|
+
class YourForkomaticClass < Forkomatic
|
12
|
+
class Job < Forkomatic::Job
|
13
|
+
attr_accessor :data
|
14
|
+
|
15
|
+
def initialize(data)
|
16
|
+
self.data = data
|
17
|
+
end
|
18
|
+
|
19
|
+
def work!
|
20
|
+
puts "Working on #{data}"
|
21
|
+
sleep 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_jobs(count)
|
26
|
+
(1..count).each.collect {|i| YourForkomaticClass::Job.new(i)}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# To just create 20 child processes:
|
31
|
+
Forkomatic.new(20)
|
32
|
+
|
33
|
+
# 10 child processes will be maintained, and the loop will will run twice, waiting 1 second between iterations.
|
34
|
+
Forkomatic.new({:max_children => 10, :work_interval => 1, :max_iterations => 2})
|
35
|
+
|
36
|
+
# The work function will run continuously, adding new child processes as old ones die to maintain a constant 10 processes.
|
37
|
+
Forkomatic.new({:max_children => 10, :work_interval => 1})
|
38
|
+
|
39
|
+
* Override the Job initialize function to give your child processes data to work with.
|
40
|
+
* Override the Job work! function to do whatever processing is required.
|
41
|
+
* Override the Forkomatic build_jobs() function to create 'count' child processes as needed.
|
42
|
+
* Create a new instance of your Forkomatic class by giving it a number of processes to create or manually specifying parameters.
|
43
|
+
|
44
|
+
== Examples
|
45
|
+
* Examples are found in the test/ directory
|
4
46
|
|
5
47
|
== Contributing to forkomatic
|
6
48
|
|
@@ -12,8 +54,14 @@ Description goes here.
|
|
12
54
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
55
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
56
|
|
57
|
+
== Related projects
|
58
|
+
forkify: https://github.com/dakrone/forkify
|
59
|
+
* based on forkoff and threadify, used to processes a bunch of data using 'n' processes. Limited to one iteration, but very simple to use.
|
60
|
+
|
61
|
+
forkoff: https://github.com/ahoward/forkoff
|
62
|
+
* works on enumerable objects, iterating a code block to run in each child processes and collecting results. Also limited to a single iteration.
|
63
|
+
|
15
64
|
== Copyright
|
16
65
|
|
17
66
|
Copyright (c) 2012 Jon Durbin. See LICENSE.txt for
|
18
67
|
further details.
|
19
|
-
|
data/Rakefile
CHANGED
@@ -18,10 +18,10 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.homepage = "http://github.com/gdi/forkomatic"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = %Q{Easily run multiple processes continuously in parallel.}
|
21
|
-
gem.description = %Q{Easily create parallel processes to do work
|
21
|
+
gem.description = %Q{Easily create parallel processes to do work, continuously maintain a number of processes or perform a single iteration, etc.}
|
22
22
|
gem.email = "jond@greenviewdata.com"
|
23
23
|
gem.authors = ["Jon Durbin"]
|
24
|
-
gem.version = '0.0.
|
24
|
+
gem.version = '0.0.2'
|
25
25
|
# dependencies defined in Gemfile
|
26
26
|
end
|
27
27
|
Jeweler::RubygemsDotOrgTasks.new
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forkomatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jon Durbin
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
name: rdoc
|
79
79
|
version_requirements: *id004
|
80
80
|
prerelease: false
|
81
|
-
description: Easily create parallel processes to do work
|
81
|
+
description: Easily create parallel processes to do work, continuously maintain a number of processes or perform a single iteration, etc.
|
82
82
|
email: jond@greenviewdata.com
|
83
83
|
executables: []
|
84
84
|
|