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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/parallelizer.rb +10 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3692433bc34de9a11efa83488022b791f54f6e4
4
- data.tar.gz: 07c99835d3d52c65f81573790c88a5e64e4810ec
3
+ metadata.gz: ffdc96e5e6053f0dd5ebc81382d4c673fbd74772
4
+ data.tar.gz: 7cb52c42d82b72f603dbd10f440617db86620048
5
5
  SHA512:
6
- metadata.gz: 51c3d72d22b20a22c613ca0c0922e33a58a8989eabc42b402fc0da7bbe7955e7ff07274bb317c03f9417025be3d0db21842a81df531fb7c04b09ca5c4c0b4db7
7
- data.tar.gz: 81579a4a0482dc559a1f5202cf16ae4d47ee95d1053a539bd9292543b4e2625b36ff9ab36e5e901712ed2a8090a641c28edc019c751ca3aa68ab450bf1b2e7eb
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 enumerator.map {|arg| Computation.new(self, proc, arg) }
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 array.map {|proc| Computation.new(self, proc) }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: java
6
6
  authors:
7
7
  - Mohamed Hafez