parallel 1.23.0 → 1.24.0
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/parallel/version.rb +1 -1
- data/lib/parallel.rb +25 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7b4a5662ef68724c75c2d655d9bd09ad109edc02d3199a0744093544608f74b
|
|
4
|
+
data.tar.gz: 247f7f3745c42cdafeb5d403fff250e99b99a56d4dc4948050dcf20ecb60d183
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18f62ea9fefb30bda9b89f0189074da99572c5c17fb93ba28e553b0eb9f6d7a61bd70ba423004b138b05c3c86f8e04fd32fce81da40a68c0bdca39e263b8b892
|
|
7
|
+
data.tar.gz: dca61c9e3cab22de0ad064c96c55afc88177214108d6bdbfb8e9a93343f23d6ee321c83aa6c4cfa9ee33da79d01802d7b952f3dd0360f9cca26e5da78a4117fa
|
data/lib/parallel/version.rb
CHANGED
data/lib/parallel.rb
CHANGED
|
@@ -640,10 +640,34 @@ module Parallel
|
|
|
640
640
|
end
|
|
641
641
|
|
|
642
642
|
def instrument_finish(item, index, result, options)
|
|
643
|
-
return unless on_finish = options[:finish]
|
|
643
|
+
return unless (on_finish = options[:finish])
|
|
644
|
+
return instrument_finish_in_order(item, index, result, options) if options[:finish_in_order]
|
|
644
645
|
options[:mutex].synchronize { on_finish.call(item, index, result) }
|
|
645
646
|
end
|
|
646
647
|
|
|
648
|
+
# yield results in the order of the input items
|
|
649
|
+
# needs to use `options` to store state between executions
|
|
650
|
+
# needs to use `done` index since a nil result would also be valid
|
|
651
|
+
def instrument_finish_in_order(item, index, result, options)
|
|
652
|
+
options[:mutex].synchronize do
|
|
653
|
+
# initialize our state
|
|
654
|
+
options[:finish_done] ||= []
|
|
655
|
+
options[:finish_expecting] ||= 0 # we wait for item at index 0
|
|
656
|
+
|
|
657
|
+
# store current result
|
|
658
|
+
options[:finish_done][index] = [item, result]
|
|
659
|
+
|
|
660
|
+
# yield all results that are now in order
|
|
661
|
+
break unless index == options[:finish_expecting]
|
|
662
|
+
index.upto(options[:finish_done].size).each do |i|
|
|
663
|
+
break unless (done = options[:finish_done][i])
|
|
664
|
+
options[:finish_done][i] = nil # allow GC to free this item and result
|
|
665
|
+
options[:finish].call(done[0], i, done[1])
|
|
666
|
+
options[:finish_expecting] += 1
|
|
667
|
+
end
|
|
668
|
+
end
|
|
669
|
+
end
|
|
670
|
+
|
|
647
671
|
def instrument_start(item, index, options)
|
|
648
672
|
return unless on_start = options[:start]
|
|
649
673
|
options[:mutex].synchronize { on_start.call(item, index) }
|
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.
|
|
4
|
+
version: 1.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Grosser
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: michael@grosser.it
|
|
@@ -24,8 +24,8 @@ licenses:
|
|
|
24
24
|
- MIT
|
|
25
25
|
metadata:
|
|
26
26
|
bug_tracker_uri: https://github.com/grosser/parallel/issues
|
|
27
|
-
documentation_uri: https://github.com/grosser/parallel/blob/v1.
|
|
28
|
-
source_code_uri: https://github.com/grosser/parallel/tree/v1.
|
|
27
|
+
documentation_uri: https://github.com/grosser/parallel/blob/v1.24.0/Readme.md
|
|
28
|
+
source_code_uri: https://github.com/grosser/parallel/tree/v1.24.0
|
|
29
29
|
wiki_uri: https://github.com/grosser/parallel/wiki
|
|
30
30
|
post_install_message:
|
|
31
31
|
rdoc_options: []
|