parallel 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f363b126a1d42e09e74864a71c940edaf139d79
4
- data.tar.gz: a8976de6367828f3ef06b8eb81822515817b1afc
3
+ metadata.gz: 70d72f94264963ccffda50fb09447556b91cb288
4
+ data.tar.gz: 5941637ecb8f9252001ac5e73fee8abd038dddb9
5
5
  SHA512:
6
- metadata.gz: 0a78ebb2abf7b12749b4ffb318eb70b8b04f00af516dcf438423080a26136bd2a87a097e9b593130294eaf4e9a1e97a754da7c8f7a7a46c7d7b84f5446bdd224
7
- data.tar.gz: 3eb8871382f2669e89fecca80bc2dfe198c05df133795e55fd12bd283d0760d7a9c5035c2abc337431b57048647b343ea9022a3ca83bf4da875c53d8a47c3b0c
6
+ metadata.gz: 307b3c2200b61a209480844057b2778bd53c342af0ef63adb922daeb145ebeba0af27cf8fc826d90d126dca4e293b80c88fe8e7e496c7e91aea3dfb74e550a1f
7
+ data.tar.gz: b4a12fcac78745faa6027000375e4f395f9b478fe912d18baefdc584152198e3e97fba56020f8a7cfac0f66c59f8eb05ec65fd8019275e4a4bad3232ea4aaa07
@@ -99,10 +99,13 @@ module Parallel
99
99
  end
100
100
  end
101
101
 
102
+ # generate item that is sent to workers
103
+ # just index is faster + less likely to blow up with unserializable errors
102
104
  def pack(item, index)
103
105
  producer? ? [item, index] : index
104
106
  end
105
107
 
108
+ # unpack item that is sent to workers
106
109
  def unpack(data)
107
110
  producer? ? data : [@source[data], data]
108
111
  end
@@ -273,6 +276,7 @@ module Parallel
273
276
  def work_in_threads(job_factory, options, &block)
274
277
  raise "interrupt_signal is no longer supported for threads" if options[:interrupt_signal]
275
278
  results = []
279
+ results_mutex = Mutex.new # arrays are not thread-safe on jRuby
276
280
  exception = nil
277
281
 
278
282
  in_threads(options) do
@@ -280,9 +284,10 @@ module Parallel
280
284
  while !exception && set = job_factory.next
281
285
  begin
282
286
  item, index = set
283
- results[index] = with_instrumentation item, index, options do
287
+ result = with_instrumentation item, index, options do
284
288
  call_with_index(item, index, options, &block)
285
289
  end
290
+ results_mutex.synchronize { results[index] = result }
286
291
  rescue StandardError => e
287
292
  exception = e
288
293
  end
@@ -295,6 +300,7 @@ module Parallel
295
300
  def work_in_processes(job_factory, options, &blk)
296
301
  workers = create_workers(job_factory, options, &blk)
297
302
  results = []
303
+ results_mutex = Mutex.new # arrays are not thread-safe
298
304
  exception = nil
299
305
 
300
306
  UserInterruptHandler.kill_on_ctrl_c(workers.map(&:pid), options) do
@@ -309,9 +315,10 @@ module Parallel
309
315
  break unless index
310
316
 
311
317
  begin
312
- results[index] = with_instrumentation item, index, options do
318
+ result = with_instrumentation item, index, options do
313
319
  worker.work(job_factory.pack(item, index))
314
320
  end
321
+ results_mutex.synchronize { results[index] = result } # arrays are not threads safe on jRuby
315
322
  rescue StandardError => e
316
323
  exception = e
317
324
  if Parallel::Kill === exception
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.6.0'
2
+ VERSION = Version = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it