parallel 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/Readme.md +3 -1
- data/VERSION +1 -1
- data/lib/parallel.rb +9 -6
- data/parallel.gemspec +22 -21
- metadata +25 -25
data/Rakefile
CHANGED
@@ -12,9 +12,10 @@ begin
|
|
12
12
|
gem.email = "grosser.michael@gmail.com"
|
13
13
|
gem.homepage = "http://github.com/grosser/#{gem.name}"
|
14
14
|
gem.authors = ["Michael Grosser"]
|
15
|
+
gem.license = "MIT"
|
15
16
|
end
|
16
17
|
|
17
18
|
Jeweler::GemcutterTasks.new
|
18
19
|
rescue LoadError
|
19
20
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
20
|
-
end
|
21
|
+
end
|
data/Readme.md
CHANGED
@@ -61,7 +61,9 @@ Authors
|
|
61
61
|
- [Byron Bowerman](http://me.bm5k.com/)
|
62
62
|
- [Mikko Kokkonen](https://github.com/mikian)
|
63
63
|
- [brian p o'rourke](https://github.com/bpo)
|
64
|
+
- [Norio Sato]
|
64
65
|
|
65
66
|
[Michael Grosser](http://grosser.it)<br/>
|
66
67
|
michael@grosser.it<br/>
|
67
|
-
|
68
|
+
License: MIT<br/>
|
69
|
+
[![Flattr](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=grosser&url=https://github.com/grosser/parallel&title=parallel&language=en_GB&tags=github&category=software)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.10
|
data/lib/parallel.rb
CHANGED
@@ -125,17 +125,13 @@ class Parallel
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def self.work_in_processes(items, options, &blk)
|
128
|
+
workers = create_workers(items, options, &blk)
|
128
129
|
current_index = -1
|
129
130
|
results = []
|
130
|
-
pids = []
|
131
131
|
exception = nil
|
132
132
|
|
133
|
-
kill_on_ctrl_c(pids)
|
134
|
-
|
135
133
|
in_threads(options[:count]) do |i|
|
136
|
-
|
137
|
-
worker = worker(items, options, &blk)
|
138
|
-
pids[i] = worker[:pid]
|
134
|
+
worker = workers[i]
|
139
135
|
|
140
136
|
begin
|
141
137
|
loop do
|
@@ -166,6 +162,13 @@ class Parallel
|
|
166
162
|
results
|
167
163
|
end
|
168
164
|
|
165
|
+
def self.create_workers(items, options, &block)
|
166
|
+
workers = Array.new(options[:count]).map{ worker(items, options, &block) }
|
167
|
+
pids = workers.map{|worker| worker[:pid] }
|
168
|
+
kill_on_ctrl_c(pids)
|
169
|
+
workers
|
170
|
+
end
|
171
|
+
|
169
172
|
def self.worker(items, options, &block)
|
170
173
|
# use less memory on REE
|
171
174
|
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
|
data/parallel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{parallel}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-12-06}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.files = [
|
15
15
|
"Gemfile",
|
@@ -45,35 +45,36 @@ Gem::Specification.new do |s|
|
|
45
45
|
"spec/spec_helper.rb"
|
46
46
|
]
|
47
47
|
s.homepage = %q{http://github.com/grosser/parallel}
|
48
|
+
s.licenses = ["MIT"]
|
48
49
|
s.rdoc_options = ["--charset=UTF-8"]
|
49
50
|
s.require_paths = ["lib"]
|
50
51
|
s.rubygems_version = %q{1.6.2}
|
51
52
|
s.summary = %q{Run any kind of code in parallel processes}
|
52
53
|
s.test_files = [
|
53
|
-
"spec/
|
54
|
-
"spec/
|
55
|
-
"spec/cases/parallel_influence_outside_data.rb",
|
56
|
-
"spec/cases/no_dump_with_each.rb",
|
57
|
-
"spec/cases/parallel_map.rb",
|
58
|
-
"spec/cases/host_os_override_processor_count.rb",
|
54
|
+
"spec/spec_helper.rb",
|
55
|
+
"spec/parallel_spec.rb",
|
59
56
|
"spec/cases/map_with_index_empty.rb",
|
60
|
-
"spec/cases/parallel_with_nil_uses_detected_cpus.rb",
|
61
|
-
"spec/cases/map_with_threads_and_exceptions.rb",
|
62
|
-
"spec/cases/closes_processes_at_runtime.rb",
|
63
|
-
"spec/cases/parallel_high_fork_rate.rb",
|
64
|
-
"spec/cases/map_with_processes_and_exceptions.rb",
|
65
57
|
"spec/cases/parallel_map_range.rb",
|
66
|
-
"spec/cases/
|
67
|
-
"spec/cases/
|
68
|
-
"spec/cases/
|
69
|
-
"spec/cases/each_with_index.rb",
|
70
|
-
"spec/cases/map_with_index.rb",
|
58
|
+
"spec/cases/map_with_threads_and_exceptions.rb",
|
59
|
+
"spec/cases/parallel_influence_outside_data.rb",
|
60
|
+
"spec/cases/parallel_with_set_processes.rb",
|
71
61
|
"spec/cases/parallel_with_detected_cpus.rb",
|
62
|
+
"spec/cases/parallel_start_and_kill.rb",
|
72
63
|
"spec/cases/parallel_sleeping_2.rb",
|
73
|
-
"spec/cases/
|
64
|
+
"spec/cases/host_os_override_processor_count.rb",
|
65
|
+
"spec/cases/map_with_index.rb",
|
74
66
|
"spec/cases/map_with_nested_arrays_and_nil.rb",
|
75
|
-
"spec/
|
76
|
-
"spec/
|
67
|
+
"spec/cases/parallel_map_uneven.rb",
|
68
|
+
"spec/cases/parallel_map_sleeping.rb",
|
69
|
+
"spec/cases/each_with_index.rb",
|
70
|
+
"spec/cases/map_with_processes_and_exceptions.rb",
|
71
|
+
"spec/cases/no_dump_with_each.rb",
|
72
|
+
"spec/cases/parallel_raise.rb",
|
73
|
+
"spec/cases/parallel_high_fork_rate.rb",
|
74
|
+
"spec/cases/parallel_map.rb",
|
75
|
+
"spec/cases/each.rb",
|
76
|
+
"spec/cases/closes_processes_at_runtime.rb",
|
77
|
+
"spec/cases/parallel_with_nil_uses_detected_cpus.rb"
|
77
78
|
]
|
78
79
|
|
79
80
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 10
|
10
|
+
version: 0.5.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-06 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -61,8 +61,8 @@ files:
|
|
61
61
|
- spec/spec_helper.rb
|
62
62
|
has_rdoc: true
|
63
63
|
homepage: http://github.com/grosser/parallel
|
64
|
-
licenses:
|
65
|
-
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
66
|
post_install_message:
|
67
67
|
rdoc_options:
|
68
68
|
- --charset=UTF-8
|
@@ -94,27 +94,27 @@ signing_key:
|
|
94
94
|
specification_version: 3
|
95
95
|
summary: Run any kind of code in parallel processes
|
96
96
|
test_files:
|
97
|
-
- spec/
|
98
|
-
- spec/
|
99
|
-
- spec/cases/parallel_influence_outside_data.rb
|
100
|
-
- spec/cases/no_dump_with_each.rb
|
101
|
-
- spec/cases/parallel_map.rb
|
102
|
-
- spec/cases/host_os_override_processor_count.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
- spec/parallel_spec.rb
|
103
99
|
- spec/cases/map_with_index_empty.rb
|
104
|
-
- spec/cases/parallel_with_nil_uses_detected_cpus.rb
|
105
|
-
- spec/cases/map_with_threads_and_exceptions.rb
|
106
|
-
- spec/cases/closes_processes_at_runtime.rb
|
107
|
-
- spec/cases/parallel_high_fork_rate.rb
|
108
|
-
- spec/cases/map_with_processes_and_exceptions.rb
|
109
100
|
- spec/cases/parallel_map_range.rb
|
110
|
-
- spec/cases/
|
111
|
-
- spec/cases/
|
112
|
-
- spec/cases/
|
113
|
-
- spec/cases/each_with_index.rb
|
114
|
-
- spec/cases/map_with_index.rb
|
101
|
+
- spec/cases/map_with_threads_and_exceptions.rb
|
102
|
+
- spec/cases/parallel_influence_outside_data.rb
|
103
|
+
- spec/cases/parallel_with_set_processes.rb
|
115
104
|
- spec/cases/parallel_with_detected_cpus.rb
|
105
|
+
- spec/cases/parallel_start_and_kill.rb
|
116
106
|
- spec/cases/parallel_sleeping_2.rb
|
117
|
-
- spec/cases/
|
107
|
+
- spec/cases/host_os_override_processor_count.rb
|
108
|
+
- spec/cases/map_with_index.rb
|
118
109
|
- spec/cases/map_with_nested_arrays_and_nil.rb
|
119
|
-
- spec/
|
120
|
-
- spec/
|
110
|
+
- spec/cases/parallel_map_uneven.rb
|
111
|
+
- spec/cases/parallel_map_sleeping.rb
|
112
|
+
- spec/cases/each_with_index.rb
|
113
|
+
- spec/cases/map_with_processes_and_exceptions.rb
|
114
|
+
- spec/cases/no_dump_with_each.rb
|
115
|
+
- spec/cases/parallel_raise.rb
|
116
|
+
- spec/cases/parallel_high_fork_rate.rb
|
117
|
+
- spec/cases/parallel_map.rb
|
118
|
+
- spec/cases/each.rb
|
119
|
+
- spec/cases/closes_processes_at_runtime.rb
|
120
|
+
- spec/cases/parallel_with_nil_uses_detected_cpus.rb
|