parallel 1.2.2 → 1.2.3

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: e26f6721425c56c0c45ca69a2301136ffeeb520b
4
- data.tar.gz: 68ecf7b9f6eac61c89546c500653c17260f4952c
3
+ metadata.gz: 4335cc7d93938d3aafdb07fee7a4aa32e7b586c7
4
+ data.tar.gz: 718327edc760a05b8d8502ed1afdb334a1fb1ef1
5
5
  SHA512:
6
- metadata.gz: 17eab2e1bc6367300fc2cdd780e3378978bc0cb78a2ca9cdfdd16917658a697cf8a808587eb851a1a30e8829916bcff9a9b7d4230ea78e1f182b57d75a2c1716
7
- data.tar.gz: d72aee9ea542f2032d04e1da09acaa50897f949ca9a178212d57a4a557b5cc42e7d27e776bf539e135840ec2d83947c91c732735fdc38760b33085f4c91bc792
6
+ metadata.gz: 1d4c4d72297c1e8e0da33d05e111d7eb32e58c0f7d759329abd1c5f9a90c17711bf23202f75ad647414194284747b8d493073a11cc024e4351633a743526f6aa
7
+ data.tar.gz: 2dc97cc4d85eb122faa0cdade2de92d5889a14eed7fe08527c4cc3562d5fc8c2ae7571842a3c44bfc69fdb726aab5e19a90102a164a7884de93ac0291558df46
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- �����,���C�H���d4�`�ߗ+Tf�@�<�`K%����>����]�l����_���Հ,���+�J�WUt�ĦY���X������Ǐ�,���� xNHe����F�\�Nߞ�`�jl���70��
2
- ����j(4�f�OY6SnM1�7�c�����#��W/��w6�����V���;���B��F|�'��޻�Žq z 3�^�'�ɳ02�ǩz
3
- �{�3sA�e�{�yah�V�I�?+�b
1
+ ]��� a��FmS%�Mϓh���u���M�m���BE��#��&.X��S�ၓ38aaJ~�>�巣�����=���nD;{�EhMzsp�R��; ���:�C�^Gώ����Y��&2��H4�~����"e�݈���O��1�ɖPtR
2
+ �!��$d�-�B��<�L "�ȗ�Z{�c���ԃ�~�F/�'t"brMh��.9k-5"o�� �a�|�kt\#9�xt�4�_е�����*�qI/�F
data/lib/parallel.rb CHANGED
@@ -84,7 +84,7 @@ module Parallel
84
84
  end
85
85
 
86
86
  def each(array, options={}, &block)
87
- map(array, options.merge(:preserve_results => false), &block)
87
+ map(array, options.merge(:preserve_results => !!options[:finish]), &block)
88
88
  array
89
89
  end
90
90
 
@@ -94,6 +94,7 @@ module Parallel
94
94
 
95
95
  def map(array, options = {}, &block)
96
96
  array = array.to_a # turn Range and other Enumerable-s into an Array
97
+ options[:mutex] ||= Mutex.new
97
98
 
98
99
  if RUBY_PLATFORM =~ /java/ and not options[:in_processes]
99
100
  method = :in_threads
@@ -124,14 +125,18 @@ module Parallel
124
125
  end
125
126
 
126
127
  def add_progress_bar!(array, options)
127
- if (title = options[:progress]) && !options[:finish]
128
+ if title = options[:progress]
128
129
  require 'ruby-progressbar'
129
130
  progress = ProgressBar.create(
130
131
  :title => title,
131
132
  :total => array.size,
132
133
  :format => '%t |%E | %B | %a'
133
134
  )
134
- options[:finish] = lambda { |item, i, result| progress.increment }
135
+ old_finish = options[:finish]
136
+ options[:finish] = lambda do |item, i, result|
137
+ old_finish.call(item, i, result) if old_finish
138
+ progress.increment
139
+ end
135
140
  end
136
141
  end
137
142
 
@@ -442,10 +447,10 @@ module Parallel
442
447
  def with_instrumentation(item, index, options)
443
448
  on_start = options[:start]
444
449
  on_finish = options[:finish]
445
- on_start.call(item, index) if on_start
450
+ options[:mutex].synchronize { on_start.call(item, index) } if on_start
446
451
  result = yield
447
452
  ensure
448
- on_finish.call(item, index, result) if on_finish
453
+ options[:mutex].synchronize { on_finish.call(item, index, result) } if on_finish
449
454
  end
450
455
  end
451
456
  end
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.2.2'
2
+ VERSION = Version = '1.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -30,7 +30,7 @@ cert_chain:
30
30
  F5etKHZg0j3eHO31/i2HnswY04lqGImUu6aM5EnijFTB7PPW2KwKKM4+kKDYFdlw
31
31
  /0WV1Ng2/Y6qsHwmqGg2VlYj2h4=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-08-12 00:00:00.000000000 Z
33
+ date: 2014-08-17 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email: michael@grosser.it
metadata.gz.sig CHANGED
Binary file