parallelizer 0.0.4-java → 0.0.5-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/parallelizer.rb +10 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffdc96e5e6053f0dd5ebc81382d4c673fbd74772
|
4
|
+
data.tar.gz: 7cb52c42d82b72f603dbd10f440617db86620048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f99e7c73a77e152fd890cc93358b758f1f8b00de0bfeb9a6cf47dd8c67837ca39c0903267f6e43eef4c35ddf43508c974c23ffd28af4808d5d8db0000632379
|
7
|
+
data.tar.gz: 0c3813aa65459373a3c2134953ac23a03d9fcd5ddb37c120eb1d5e2eb95bda2330efd516dc699ddd9239c55e52f9e084d38957d8a514d5ea69e1b9a570c0f3fd
|
data/lib/parallelizer.rb
CHANGED
@@ -55,13 +55,13 @@ class Parallelizer
|
|
55
55
|
|
56
56
|
#works like a normal map, but in parallel, and also if an exception is raised that exception
|
57
57
|
#will be stored in that index instead of the result
|
58
|
-
def map enumerator, &proc
|
59
|
-
run_computation_array
|
58
|
+
def map enumerator, ops={}, &proc
|
59
|
+
run_computation_array(enumerator.map {|arg| Computation.new(self, proc, arg) }, ops)
|
60
60
|
end
|
61
61
|
|
62
62
|
#expects an array of procs
|
63
|
-
def run array
|
64
|
-
run_computation_array
|
63
|
+
def run array, ops={}
|
64
|
+
run_computation_array(array.map {|proc| Computation.new(self, proc) }, ops)
|
65
65
|
end
|
66
66
|
|
67
67
|
protected
|
@@ -96,7 +96,7 @@ class Parallelizer
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
def run_computation_array computation_array
|
99
|
+
def run_computation_array computation_array, ops
|
100
100
|
results_array = Array.new(computation_array.size)
|
101
101
|
future_tasks = []
|
102
102
|
computation_array.each_with_index {|comp, i|
|
@@ -119,6 +119,11 @@ class Parallelizer
|
|
119
119
|
}
|
120
120
|
|
121
121
|
future_tasks.each {|task| task.get } #wait for all tasks to complete
|
122
|
+
|
123
|
+
if ops[:auto_raise] && (e = results_array.detect {|r| r.kind_of? Exception })
|
124
|
+
raise e
|
125
|
+
end
|
126
|
+
|
122
127
|
results_array
|
123
128
|
end
|
124
129
|
end
|