in_threads 1.5.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/check.yml +51 -0
- data/.github/workflows/rubocop.yml +16 -0
- data/.rubocop.yml +17 -3
- data/CHANGELOG.markdown +7 -0
- data/Gemfile +0 -4
- data/LICENSE.txt +1 -1
- data/README.markdown +23 -12
- data/in_threads.gemspec +4 -3
- data/lib/in_threads.rb +42 -19
- data/spec/in_threads_spec.rb +55 -19
- metadata +29 -14
- data/.travis.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab96a79a5ad21d6198f4c91e689a37343371ca5932a30d695c91f8f8949a9c5
|
4
|
+
data.tar.gz: 91e41ba4f9073cff55f925e40cbc8728893974ec365a440b1f57cafd315ce4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c03797c1506c3bc73b1fd8191ba931f21c63c30e56a897bc309815a461eaa2baa368e7daa88a2023113c954c1016666f0b267cfa11b01455d59b3af4d0999f7
|
7
|
+
data.tar.gz: 274d7a37b752f0f673eb575a348422999b177cdd56e9519f11dbbee0305bd16b17aceccdfd08f1c2ba12b46c8119a309e1a4cc88f8ff3be6078940dc579f96f0
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: check
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
pull_request:
|
5
|
+
schedule:
|
6
|
+
- cron: 45 4 * * 3
|
7
|
+
jobs:
|
8
|
+
check:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby:
|
13
|
+
- '2.0'
|
14
|
+
- '2.1'
|
15
|
+
- '2.2'
|
16
|
+
- '2.3'
|
17
|
+
- '2.4'
|
18
|
+
- '2.5'
|
19
|
+
- '2.6'
|
20
|
+
- '2.7'
|
21
|
+
- '3.0'
|
22
|
+
- '3.1'
|
23
|
+
- jruby-9.1
|
24
|
+
- jruby-9.2
|
25
|
+
- jruby-9.3
|
26
|
+
include:
|
27
|
+
- ruby: ruby-head
|
28
|
+
allow-failure: allow-failure
|
29
|
+
fail-fast: false
|
30
|
+
continue-on-error: ${{ matrix.allow-failure && true || false }}
|
31
|
+
timeout-minutes: 5
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
- uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: "${{ matrix.ruby }}"
|
37
|
+
bundler-cache: true
|
38
|
+
- run: bundle exec rspec --format documentation
|
39
|
+
legacy:
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
container: ${{ matrix.container }}
|
42
|
+
strategy:
|
43
|
+
matrix:
|
44
|
+
container:
|
45
|
+
- rspec/ci:1.8.7
|
46
|
+
- rspec/ci:1.9.3
|
47
|
+
fail-fast: false
|
48
|
+
steps:
|
49
|
+
- uses: actions/checkout@v2
|
50
|
+
- run: bundle install
|
51
|
+
- run: bundle exec rspec --format documentation
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: rubocop
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
pull_request:
|
5
|
+
schedule:
|
6
|
+
- cron: 45 4 * * 3
|
7
|
+
jobs:
|
8
|
+
rubocop:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: '3.1'
|
15
|
+
bundler-cache: true
|
16
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- '*.gemspec'
|
4
|
+
- 'vendor/bundle/**/*'
|
5
|
+
NewCops: enable
|
4
6
|
|
5
7
|
Layout/AccessModifierIndentation:
|
6
8
|
EnforcedStyle: outdent
|
@@ -17,6 +19,9 @@ Layout/EndAlignment:
|
|
17
19
|
Layout/FirstHashElementIndentation:
|
18
20
|
EnforcedStyle: consistent
|
19
21
|
|
22
|
+
Layout/LineLength:
|
23
|
+
Max: 120
|
24
|
+
|
20
25
|
Layout/RescueEnsureAlignment:
|
21
26
|
Enabled: false
|
22
27
|
|
@@ -52,21 +57,30 @@ Metrics/ClassLength:
|
|
52
57
|
Metrics/CyclomaticComplexity:
|
53
58
|
Max: 10
|
54
59
|
|
55
|
-
Metrics/LineLength:
|
56
|
-
Max: 120
|
57
|
-
|
58
60
|
Metrics/MethodLength:
|
59
61
|
Max: 30
|
60
62
|
|
61
63
|
Style/DoubleNegation:
|
62
64
|
Enabled: false
|
63
65
|
|
66
|
+
Style/HashEachMethods:
|
67
|
+
Enabled: true
|
68
|
+
|
64
69
|
Style/HashSyntax:
|
65
70
|
EnforcedStyle: hash_rockets
|
66
71
|
|
72
|
+
Style/HashTransformKeys:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Style/HashTransformValues:
|
76
|
+
Enabled: false
|
77
|
+
|
67
78
|
Style/IfUnlessModifier:
|
68
79
|
Enabled: false
|
69
80
|
|
81
|
+
Style/OptionalBooleanParameter:
|
82
|
+
Enabled: false
|
83
|
+
|
70
84
|
Style/ParallelAssignment:
|
71
85
|
Enabled: false
|
72
86
|
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v1.6.0 (2022-01-18)
|
6
|
+
|
7
|
+
* Fix return for shortcut `enum.in_threads{ break … }` vs `enum.in_threads.each{ break … }` [@toy](https://github.com/toy)
|
8
|
+
* Switch `each_with_object` to run in threads, unlike inject/reduce there is no contradiction, care should be taken if passed object is not thread safe [@toy](https://github.com/toy)
|
9
|
+
* Switch `to_h` (ruby >= 2.6) and `to_set` to run in threads, they accept block to apply before creating Hash and Set respectively [@toy](https://github.com/toy)
|
10
|
+
* Register `compact` added in 3.1 to run without threads (as it doesn't accept block) [@toy](https://github.com/toy)
|
11
|
+
|
5
12
|
## v1.5.4 (2019-12-26)
|
6
13
|
|
7
14
|
* Register `filter_map` to run in threads and `tally` to run without threads (as it doesn't accept block) [@toy](https://github.com/toy)
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.markdown
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
[![Gem Version](https://img.shields.io/gem/v/in_threads
|
2
|
-
[![Build Status](https://img.shields.io/
|
3
|
-
[![Code Climate](https://img.shields.io/codeclimate/maintainability/toy/in_threads
|
4
|
-
[![Depfu](https://
|
5
|
-
[![Inch CI](https://inch-ci.org/github/toy/in_threads.svg?branch=master
|
1
|
+
[![Gem Version](https://img.shields.io/gem/v/in_threads?logo=rubygems)](https://rubygems.org/gems/in_threads)
|
2
|
+
[![Build Status](https://img.shields.io/github/workflow/status/toy/in_threads/check/master?logo=github)](https://github.com/toy/in_threads/actions/workflows/check.yml)
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/maintainability/toy/in_threads?logo=codeclimate)](https://codeclimate.com/github/toy/in_threads)
|
4
|
+
[![Depfu](https://img.shields.io/depfu/toy/in_threads)](https://depfu.com/github/toy/in_threads)
|
5
|
+
[![Inch CI](https://inch-ci.org/github/toy/in_threads.svg?branch=master)](https://inch-ci.org/github/toy/in_threads)
|
6
6
|
|
7
7
|
# in_threads
|
8
8
|
|
@@ -25,13 +25,13 @@ gem 'in_threads'
|
|
25
25
|
...and install it with [Bundler](http://bundler.io).
|
26
26
|
|
27
27
|
```sh
|
28
|
-
|
28
|
+
bundle install
|
29
29
|
```
|
30
30
|
|
31
31
|
Or install globally:
|
32
32
|
|
33
33
|
```sh
|
34
|
-
|
34
|
+
gem install in_threads
|
35
35
|
```
|
36
36
|
|
37
37
|
## Usage
|
@@ -90,9 +90,20 @@ urls.in_threads.all? { |url| HTTP.get(url).status == 200 }
|
|
90
90
|
urls.in_threads.any? { |url| HTTP.get(url).status == 404 }
|
91
91
|
```
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
### Compatibility
|
94
|
+
|
95
|
+
All methods of `Enumerable` with a block can be used if block calls are evaluated independently, so following will
|
96
|
+
|
97
|
+
`all?`, `any?`, `collect_concat`, `collect`, `count`, `cycle`, `detect`, `drop_while`, `each_cons`, `each_entry`,
|
98
|
+
`each_slice`, `each_with_index`, `each_with_object`, `each`, `enum_cons`, `enum_slice`, `enum_with_index`,
|
99
|
+
`filter_map`, `filter`, `find_all`, `find_index`, `find`, `flat_map`, `group_by`, `map`, `max_by`, `min_by`,
|
100
|
+
`minmax_by`, `none?`, `one?`, `partition`, `reject`, `reverse_each`, `select`, `sort_by`, `sum`, `take_while`, `to_h`,
|
101
|
+
`to_set`, `uniq`, `zip`.
|
102
|
+
|
103
|
+
Following either don't accept block (like `first`), depend on previous block evaluation (like `inject`) or return an enumerator (like `chunk`), so will simply act as if `in_threads` wasn't used:
|
104
|
+
|
105
|
+
`chain`, `chunk_while`, `chunk`, `compact`, `drop`, `entries`, `first`, `include?`, `inject`, `lazy`, `max`, `member?`,
|
106
|
+
`minmax`, `min`, `reduce`, `slice_after`, `slice_before`, `slice_when`, `sort`, `take`, `tally`, `to_a`.
|
96
107
|
|
97
108
|
### Break and exceptions
|
98
109
|
|
@@ -100,8 +111,8 @@ Exceptions are caught and re-thrown after allowing blocks that are still running
|
|
100
111
|
|
101
112
|
**IMPORTANT**: only the first encountered exception is propagated, so it is recommended to handle exceptions in the block.
|
102
113
|
|
103
|
-
`break` is handled in ruby >= 1.9 and should be handled in jruby [after 9.1.9.0](https://github.com/jruby/jruby/issues/4697). Handling is done in special way: as blocks are run outside of original context, calls to `break` cause `LocalJumpError` which is caught and its result is returned.
|
114
|
+
`break` is handled in ruby >= 1.9 and should be handled in jruby [9.1 after 9.1.9.0](https://github.com/jruby/jruby/issues/4697) and [9.2 and 9.3 after #7009](https://github.com/jruby/jruby/issues/7009). Handling is done in special way: as blocks are run outside of original context, calls to `break` cause `LocalJumpError` which is caught and its result is returned.
|
104
115
|
|
105
116
|
## Copyright
|
106
117
|
|
107
|
-
Copyright (c) 2009-
|
118
|
+
Copyright (c) 2009-2022 Ivan Kuchin. See LICENSE.txt for details.
|
data/in_threads.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'in_threads'
|
5
|
-
s.version = '1.
|
5
|
+
s.version = '1.6.0'
|
6
6
|
s.summary = %q{Run all possible enumerable methods in concurrent/parallel threads}
|
7
7
|
s.homepage = "https://github.com/toy/#{s.name}"
|
8
8
|
s.authors = ['Ivan Kuchin']
|
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
s.add_development_dependency 'rspec-retry', '~> 0.3'
|
25
|
-
if RUBY_VERSION >= '2.
|
26
|
-
s.add_development_dependency 'rubocop', '~>
|
25
|
+
if RUBY_VERSION >= '2.5'
|
26
|
+
s.add_development_dependency 'rubocop', '~> 1.22', '!= 1.22.2'
|
27
|
+
s.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
27
28
|
end
|
28
29
|
end
|
data/lib/in_threads.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'thread'
|
4
4
|
require 'delegate'
|
5
|
+
require 'set'
|
5
6
|
|
6
7
|
Enumerable.class_eval do
|
7
8
|
# Run enumerable method blocks in threads
|
@@ -33,17 +34,23 @@ class InThreads < SimpleDelegator
|
|
33
34
|
protected :__getobj__, :__setobj__
|
34
35
|
|
35
36
|
attr_reader :enumerable, :thread_count
|
36
|
-
|
37
|
+
|
38
|
+
def self.new(enumerable, thread_count = 10, &block)
|
39
|
+
if block
|
40
|
+
super.each(&block)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(enumerable, thread_count = 10)
|
37
47
|
super(enumerable)
|
48
|
+
|
38
49
|
@enumerable, @thread_count = enumerable, thread_count.to_i
|
39
|
-
unless enumerable.is_a?(Enumerable)
|
40
|
-
fail ArgumentError, '`enumerable` should include Enumerable.'
|
41
|
-
end
|
42
|
-
if thread_count < 2
|
43
|
-
fail ArgumentError, '`thread_count` can\'t be less than 2.'
|
44
|
-
end
|
45
50
|
|
46
|
-
|
51
|
+
fail ArgumentError, '`enumerable` should include Enumerable.' unless enumerable.is_a?(Enumerable)
|
52
|
+
|
53
|
+
fail ArgumentError, '`thread_count` can\'t be less than 2.' if thread_count < 2
|
47
54
|
end
|
48
55
|
|
49
56
|
# Creates new instance using underlying enumerable and new thread_count
|
@@ -68,13 +75,13 @@ class InThreads < SimpleDelegator
|
|
68
75
|
next if ignore_undefined && !enumerable_method?(method)
|
69
76
|
|
70
77
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
71
|
-
def #{method}(*args, &block)
|
72
|
-
if block
|
73
|
-
#{runner}(:#{method}, *args, &block)
|
74
|
-
else
|
75
|
-
enumerable.#{method}(*args)
|
76
|
-
end
|
77
|
-
end
|
78
|
+
def #{method}(*args, &block) # def foo_bar(*args, &block)
|
79
|
+
if block # if block
|
80
|
+
#{runner}(:#{method}, *args, &block) # run_in_threads_method(:foo_bar, *args, &block)
|
81
|
+
else # else
|
82
|
+
enumerable.#{method}(*args) # enumerable.foo_bar(*args)
|
83
|
+
end # end
|
84
|
+
end # end
|
78
85
|
RUBY
|
79
86
|
end
|
80
87
|
end
|
@@ -94,6 +101,7 @@ class InThreads < SimpleDelegator
|
|
94
101
|
zip
|
95
102
|
cycle
|
96
103
|
each_entry
|
104
|
+
each_with_object
|
97
105
|
], :ignore_undefined => true
|
98
106
|
use :run_in_threads_use_block_result, :for => %w[
|
99
107
|
all? any? none? one?
|
@@ -102,22 +110,37 @@ class InThreads < SimpleDelegator
|
|
102
110
|
collect map group_by max_by min_by minmax_by sort_by sum uniq
|
103
111
|
flat_map collect_concat
|
104
112
|
filter_map
|
113
|
+
to_set
|
105
114
|
], :ignore_undefined => true
|
106
115
|
|
107
|
-
|
116
|
+
DEPENDENT_BLOCK_CALLS = %w[
|
108
117
|
inject reduce
|
109
118
|
max min minmax sort
|
110
|
-
|
119
|
+
].map(&:to_sym)
|
120
|
+
|
121
|
+
ENUMERATOR_RETURNED = %w[
|
122
|
+
chunk chunk_while slice_before slice_after slice_when
|
123
|
+
].map(&:to_sym)
|
124
|
+
|
125
|
+
BLOCKLESS_METHODS = %w[
|
126
|
+
entries to_a
|
111
127
|
drop take
|
112
128
|
first
|
113
129
|
include? member?
|
114
|
-
each_with_object
|
115
|
-
chunk chunk_while slice_before slice_after slice_when
|
116
130
|
lazy
|
117
131
|
chain
|
118
132
|
tally
|
133
|
+
compact
|
119
134
|
].map(&:to_sym)
|
120
135
|
|
136
|
+
if enumerable_method?(:to_h) && [[0, 0]].to_h{ [1, 1] } == {1 => 1}
|
137
|
+
use :run_in_threads_use_block_result, :for => %w[to_h]
|
138
|
+
else
|
139
|
+
BLOCKLESS_METHODS << :to_h
|
140
|
+
end
|
141
|
+
|
142
|
+
INCOMPATIBLE_METHODS = DEPENDENT_BLOCK_CALLS + ENUMERATOR_RETURNED + BLOCKLESS_METHODS
|
143
|
+
|
121
144
|
# Special case method, works by applying `run_in_threads_use_block_result` with
|
122
145
|
# map on enumerable returned by blockless run
|
123
146
|
def grep(*args, &block)
|
data/spec/in_threads_spec.rb
CHANGED
@@ -18,7 +18,12 @@ end
|
|
18
18
|
# not in jruby in mri < 1.9
|
19
19
|
# https://github.com/jruby/jruby/issues/4697
|
20
20
|
SKIP_IF_BREAK_IN_THREAD_IS_IGNORED = begin
|
21
|
-
|
21
|
+
proc do |&block|
|
22
|
+
Thread.new do
|
23
|
+
Thread.current.report_on_exception = false if Thread.current.respond_to?(:report_on_exception=)
|
24
|
+
block.call
|
25
|
+
end.join
|
26
|
+
end.call{ break } # rubocop:disable Style/MultilineBlockChain
|
22
27
|
'can not handle break in thread'
|
23
28
|
rescue LocalJumpError
|
24
29
|
false
|
@@ -142,6 +147,13 @@ describe InThreads do
|
|
142
147
|
end
|
143
148
|
|
144
149
|
describe 'exception/break handling' do
|
150
|
+
it 'returns identical to each when initialized with block', :skip => SKIP_IF_BREAK_IN_THREAD_IS_IGNORED do
|
151
|
+
v = double
|
152
|
+
expect(enum.each{ break v }).to eq(v) # rubocop:disable Lint/UnreachableLoop
|
153
|
+
expect(enum.in_threads{ break v }).to eq(v)
|
154
|
+
expect(enum.in_threads.each{ break v }).to eq(v) # rubocop:disable Lint/UnreachableLoop
|
155
|
+
end
|
156
|
+
|
145
157
|
%w[each map all?].each do |method|
|
146
158
|
describe "for ##{method}" do
|
147
159
|
it 'passes exception raised in block' do
|
@@ -153,7 +165,7 @@ describe InThreads do
|
|
153
165
|
fail 'expected'
|
154
166
|
end
|
155
167
|
|
156
|
-
expect{ enum.in_threads.send(method){} }.to raise_error('expected')
|
168
|
+
expect{ enum.in_threads.send(method){ nil } }.to raise_error('expected')
|
157
169
|
end
|
158
170
|
|
159
171
|
it 'handles break', :skip => SKIP_IF_BREAK_IN_THREAD_IS_IGNORED do
|
@@ -205,15 +217,18 @@ describe InThreads do
|
|
205
217
|
context 'exception order' do
|
206
218
|
before do
|
207
219
|
stub_const('Order', Queue.new)
|
220
|
+
def Order.releasing
|
221
|
+
fail 'expected'
|
222
|
+
ensure
|
223
|
+
push nil
|
224
|
+
end
|
208
225
|
end
|
209
226
|
|
210
227
|
it 'passes exception raised during iteration if it happens earlier than in block' do
|
211
228
|
def enum.each(&block)
|
212
229
|
5.times(&block)
|
213
|
-
|
230
|
+
Order.releasing do
|
214
231
|
fail 'expected'
|
215
|
-
ensure
|
216
|
-
Order.push nil
|
217
232
|
end
|
218
233
|
end
|
219
234
|
|
@@ -236,10 +251,8 @@ describe InThreads do
|
|
236
251
|
|
237
252
|
expect do
|
238
253
|
enum.in_threads(10).send(method) do
|
239
|
-
|
254
|
+
Order.releasing do
|
240
255
|
fail 'expected'
|
241
|
-
ensure
|
242
|
-
Order.push nil
|
243
256
|
end
|
244
257
|
end
|
245
258
|
end.to raise_error('expected')
|
@@ -249,10 +262,8 @@ describe InThreads do
|
|
249
262
|
expect do
|
250
263
|
enum.in_threads(10).send(method) do |i|
|
251
264
|
if i == 5
|
252
|
-
|
265
|
+
Order.releasing do
|
253
266
|
fail 'expected'
|
254
|
-
ensure
|
255
|
-
Order.push nil
|
256
267
|
end
|
257
268
|
else
|
258
269
|
Thread.pass while Order.empty?
|
@@ -511,8 +522,13 @@ describe InThreads do
|
|
511
522
|
collect map
|
512
523
|
group_by max_by min_by minmax_by sort_by
|
513
524
|
sum uniq
|
525
|
+
to_h to_set
|
514
526
|
].each do |method|
|
527
|
+
next if method == 'to_h' && InThreads::INCOMPATIBLE_METHODS.include?(:to_h)
|
528
|
+
|
515
529
|
describe_enum_method method do
|
530
|
+
let(:value_proc){ proc{ [rand] * 2 } } if method == 'to_h'
|
531
|
+
|
516
532
|
it 'returns same result with threads' do
|
517
533
|
expect(enum.in_threads.send(method, &:compute)).
|
518
534
|
to eq(enum.send(method, &:compute))
|
@@ -718,6 +734,34 @@ describe InThreads do
|
|
718
734
|
end
|
719
735
|
end
|
720
736
|
end
|
737
|
+
|
738
|
+
describe_enum_method :each_with_object do
|
739
|
+
let(:block) do
|
740
|
+
proc do |o, h|
|
741
|
+
v = o.compute
|
742
|
+
mutex.synchronize{ h[v] = true }
|
743
|
+
end
|
744
|
+
end
|
745
|
+
|
746
|
+
it 'returns same result with threads' do
|
747
|
+
expect(enum.in_threads.each_with_object({}, &block)).
|
748
|
+
to eq(enum.each_with_object({}, &block))
|
749
|
+
end
|
750
|
+
|
751
|
+
it 'yields same objects' do
|
752
|
+
yielded = []
|
753
|
+
enum.in_threads.each_with_object({}) do |o, _h|
|
754
|
+
mutex.synchronize{ yielded << o }
|
755
|
+
o.compute
|
756
|
+
end
|
757
|
+
expect(yielded).to match_array(items)
|
758
|
+
end
|
759
|
+
|
760
|
+
it 'runs faster with threads', :flaky do
|
761
|
+
expect{ enum.in_threads.each_with_object({}, &block) }.
|
762
|
+
to be_faster_than{ enum.each_with_object({}, &block) }
|
763
|
+
end
|
764
|
+
end
|
721
765
|
end
|
722
766
|
|
723
767
|
context 'unthreaded' do
|
@@ -776,14 +820,6 @@ describe InThreads do
|
|
776
820
|
end
|
777
821
|
end
|
778
822
|
|
779
|
-
describe_enum_method :each_with_object do
|
780
|
-
let(:block){ proc{ |o, h| h[o] = true } }
|
781
|
-
|
782
|
-
it 'returns same result' do
|
783
|
-
expect(enum.in_threads.each_with_object({}, &block)).to eq(enum.each_with_object({}, &block))
|
784
|
-
end
|
785
|
-
end
|
786
|
-
|
787
823
|
%w[chunk slice_before slice_after].each do |method|
|
788
824
|
describe_enum_method method do
|
789
825
|
it 'returns same result' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: in_threads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kuchin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,29 +44,44 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.22'
|
48
48
|
- - "!="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 1.22.2
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
57
|
+
version: '1.22'
|
58
58
|
- - "!="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
|
62
|
-
|
60
|
+
version: 1.22.2
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rubocop-rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.0'
|
75
|
+
description:
|
76
|
+
email:
|
63
77
|
executables: []
|
64
78
|
extensions: []
|
65
79
|
extra_rdoc_files: []
|
66
80
|
files:
|
81
|
+
- ".github/workflows/check.yml"
|
82
|
+
- ".github/workflows/rubocop.yml"
|
67
83
|
- ".gitignore"
|
68
84
|
- ".rubocop.yml"
|
69
|
-
- ".travis.yml"
|
70
85
|
- CHANGELOG.markdown
|
71
86
|
- Gemfile
|
72
87
|
- LICENSE.txt
|
@@ -80,9 +95,9 @@ licenses:
|
|
80
95
|
metadata:
|
81
96
|
bug_tracker_uri: https://github.com/toy/in_threads/issues
|
82
97
|
changelog_uri: https://github.com/toy/in_threads/blob/master/CHANGELOG.markdown
|
83
|
-
documentation_uri: https://www.rubydoc.info/gems/in_threads/1.
|
98
|
+
documentation_uri: https://www.rubydoc.info/gems/in_threads/1.6.0
|
84
99
|
source_code_uri: https://github.com/toy/in_threads
|
85
|
-
post_install_message:
|
100
|
+
post_install_message:
|
86
101
|
rdoc_options: []
|
87
102
|
require_paths:
|
88
103
|
- lib
|
@@ -97,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
112
|
- !ruby/object:Gem::Version
|
98
113
|
version: '0'
|
99
114
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
115
|
+
rubygems_version: 3.3.5
|
116
|
+
signing_key:
|
102
117
|
specification_version: 4
|
103
118
|
summary: Run all possible enumerable methods in concurrent/parallel threads
|
104
119
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
dist: trusty
|
3
|
-
language: ruby
|
4
|
-
rvm:
|
5
|
-
- '1.8.7-p374'
|
6
|
-
- '1.9.3-p551'
|
7
|
-
- '2.0.0-p648'
|
8
|
-
- '2.1.10'
|
9
|
-
- '2.2.10'
|
10
|
-
- '2.3.8'
|
11
|
-
- '2.4.9'
|
12
|
-
- '2.5.7'
|
13
|
-
- '2.6.5'
|
14
|
-
- '2.7.0'
|
15
|
-
- 'ruby-head'
|
16
|
-
- 'jruby-9.1.17.0'
|
17
|
-
- 'jruby-9.2.7.0'
|
18
|
-
before_install:
|
19
|
-
- gem install rubygems-update || gem install rubygems-update --version '< 3'
|
20
|
-
- gem update --system
|
21
|
-
- gem install bundler || gem install bundler --version '< 2'
|
22
|
-
script: bundle exec rspec
|
23
|
-
matrix:
|
24
|
-
include:
|
25
|
-
- env: RUBOCOP=✓
|
26
|
-
rvm: '2.6.5'
|
27
|
-
script: bundle exec rubocop
|
28
|
-
- env: CHECK_RUBIES=✓
|
29
|
-
rvm: '2.6.5'
|
30
|
-
script: bundle exec travis_check_rubies
|
31
|
-
allow_failures:
|
32
|
-
- rvm: 'ruby-head'
|
33
|
-
- rvm: 'jruby-9.2.7.0'
|