threads 0.4.1 → 0.5.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/Gemfile +13 -26
- data/Gemfile.lock +110 -0
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +4 -4
- data/REUSE.toml +36 -0
- data/Rakefile +3 -20
- data/lib/threads.rb +40 -26
- data/logo.svg +1 -1
- data/threads.gemspec +6 -25
- metadata +8 -24
- data/.0pdd.yml +0 -27
- data/.github/workflows/actionlint.yml +0 -43
- data/.github/workflows/codecov.yml +0 -40
- data/.github/workflows/copyrights.yml +0 -32
- data/.github/workflows/markdown-lint.yml +0 -40
- data/.github/workflows/pdd.yml +0 -36
- data/.github/workflows/rake.yml +0 -45
- data/.github/workflows/xcop.yml +0 -32
- data/.github/workflows/yamllint.yml +0 -36
- data/.gitignore +0 -8
- data/.pdd +0 -5
- data/.rubocop.yml +0 -36
- data/.rultor.yml +0 -42
- data/renovate.json +0 -6
- data/test/test__helper.rb +0 -28
- data/test/test_threads.rb +0 -80
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35751a30196f3827eac923a47ea3d72475405ad55eb46c10207385974b4d421a
|
|
4
|
+
data.tar.gz: 618ed7f1bf2d6afd9af5cb5c4ca4ca8fbdc08e861cb1526efe5276e696f26a70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f7b4de3013c5e0b37a6cfe7a10b6f4eaa6a88e67c57a55684b07941692bca5e2bdb4e1dc537c01542488c296f6f25c9abcc509b96949527a0393fe631b3ef7a
|
|
7
|
+
data.tar.gz: 54368c9d740d5af73be9f5816aae8b4af5a3bfbf731aa2b28a42ecf591a464147168a129af9a96e2c7cb36d8a6c54b16e7fb7c8a3c1fd8182a3256b0cd88a57e
|
data/Gemfile
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
source 'https://rubygems.org'
|
|
24
7
|
gemspec
|
|
25
8
|
|
|
26
|
-
gem 'minitest', '~>5', require: false
|
|
27
|
-
gem '
|
|
28
|
-
gem '
|
|
29
|
-
gem '
|
|
30
|
-
gem 'rubocop
|
|
31
|
-
gem '
|
|
32
|
-
gem '
|
|
9
|
+
gem 'minitest', '~>5.25', require: false
|
|
10
|
+
gem 'minitest-reporters', '~>1.7', require: false
|
|
11
|
+
gem 'rake', '~>13.2', require: false
|
|
12
|
+
gem 'rdoc', '~>6.12', require: false
|
|
13
|
+
gem 'rubocop', '~>1.75', require: false
|
|
14
|
+
gem 'rubocop-minitest', '~>0.38', require: false
|
|
15
|
+
gem 'rubocop-performance', '~>1.25', require: false
|
|
16
|
+
gem 'rubocop-rake', '~>0.7', require: false
|
|
17
|
+
gem 'simplecov', '~>0.22', require: false
|
|
18
|
+
gem 'simplecov-cobertura', '~>3.0', require: false
|
|
19
|
+
gem 'yard', '~>0.9', require: false
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
threads (0.0.0)
|
|
5
|
+
backtrace (~> 0)
|
|
6
|
+
concurrent-ruby (~> 1.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
ansi (1.5.0)
|
|
12
|
+
ast (2.4.3)
|
|
13
|
+
backtrace (0.4.1)
|
|
14
|
+
builder (3.3.0)
|
|
15
|
+
concurrent-ruby (1.3.5)
|
|
16
|
+
date (3.5.0)
|
|
17
|
+
docile (1.4.1)
|
|
18
|
+
erb (6.0.0)
|
|
19
|
+
json (2.16.0)
|
|
20
|
+
language_server-protocol (3.17.0.5)
|
|
21
|
+
lint_roller (1.1.0)
|
|
22
|
+
minitest (5.26.2)
|
|
23
|
+
minitest-reporters (1.7.1)
|
|
24
|
+
ansi
|
|
25
|
+
builder
|
|
26
|
+
minitest (>= 5.0)
|
|
27
|
+
ruby-progressbar
|
|
28
|
+
parallel (1.27.0)
|
|
29
|
+
parser (3.3.10.0)
|
|
30
|
+
ast (~> 2.4.1)
|
|
31
|
+
racc
|
|
32
|
+
prism (1.6.0)
|
|
33
|
+
psych (5.2.6)
|
|
34
|
+
date
|
|
35
|
+
stringio
|
|
36
|
+
racc (1.8.1)
|
|
37
|
+
rainbow (3.1.1)
|
|
38
|
+
rake (13.3.1)
|
|
39
|
+
rdoc (6.15.1)
|
|
40
|
+
erb
|
|
41
|
+
psych (>= 4.0.0)
|
|
42
|
+
tsort
|
|
43
|
+
regexp_parser (2.11.3)
|
|
44
|
+
rexml (3.4.4)
|
|
45
|
+
rubocop (1.81.7)
|
|
46
|
+
json (~> 2.3)
|
|
47
|
+
language_server-protocol (~> 3.17.0.2)
|
|
48
|
+
lint_roller (~> 1.1.0)
|
|
49
|
+
parallel (~> 1.10)
|
|
50
|
+
parser (>= 3.3.0.2)
|
|
51
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
52
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
53
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
54
|
+
ruby-progressbar (~> 1.7)
|
|
55
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
56
|
+
rubocop-ast (1.48.0)
|
|
57
|
+
parser (>= 3.3.7.2)
|
|
58
|
+
prism (~> 1.4)
|
|
59
|
+
rubocop-minitest (0.38.2)
|
|
60
|
+
lint_roller (~> 1.1)
|
|
61
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
62
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
63
|
+
rubocop-performance (1.26.1)
|
|
64
|
+
lint_roller (~> 1.1)
|
|
65
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
66
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
67
|
+
rubocop-rake (0.7.1)
|
|
68
|
+
lint_roller (~> 1.1)
|
|
69
|
+
rubocop (>= 1.72.1)
|
|
70
|
+
ruby-progressbar (1.13.0)
|
|
71
|
+
simplecov (0.22.0)
|
|
72
|
+
docile (~> 1.1)
|
|
73
|
+
simplecov-html (~> 0.11)
|
|
74
|
+
simplecov_json_formatter (~> 0.1)
|
|
75
|
+
simplecov-cobertura (3.1.0)
|
|
76
|
+
rexml
|
|
77
|
+
simplecov (~> 0.19)
|
|
78
|
+
simplecov-html (0.13.2)
|
|
79
|
+
simplecov_json_formatter (0.1.4)
|
|
80
|
+
stringio (3.1.8)
|
|
81
|
+
tsort (0.2.0)
|
|
82
|
+
unicode-display_width (3.2.0)
|
|
83
|
+
unicode-emoji (~> 4.1)
|
|
84
|
+
unicode-emoji (4.1.0)
|
|
85
|
+
yard (0.9.37)
|
|
86
|
+
|
|
87
|
+
PLATFORMS
|
|
88
|
+
arm64-darwin-22
|
|
89
|
+
arm64-darwin-23
|
|
90
|
+
arm64-darwin-24
|
|
91
|
+
x64-mingw-ucrt
|
|
92
|
+
x86_64-darwin-24
|
|
93
|
+
x86_64-linux
|
|
94
|
+
|
|
95
|
+
DEPENDENCIES
|
|
96
|
+
minitest (~> 5.25)
|
|
97
|
+
minitest-reporters (~> 1.7)
|
|
98
|
+
rake (~> 13.2)
|
|
99
|
+
rdoc (~> 6.12)
|
|
100
|
+
rubocop (~> 1.75)
|
|
101
|
+
rubocop-minitest (~> 0.38)
|
|
102
|
+
rubocop-performance (~> 1.25)
|
|
103
|
+
rubocop-rake (~> 0.7)
|
|
104
|
+
simplecov (~> 0.22)
|
|
105
|
+
simplecov-cobertura (~> 3.0)
|
|
106
|
+
threads!
|
|
107
|
+
yard (~> 0.9)
|
|
108
|
+
|
|
109
|
+
BUNDLED WITH
|
|
110
|
+
2.6.8
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/LICENSES/MIT.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included
|
|
13
|
+
in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Runs Code Block in Many Threads
|
|
2
2
|
|
|
3
3
|
[](https://www.elegantobjects.org)
|
|
4
|
-
[](https://www.rultor.com/p/yegor256/threads)
|
|
5
5
|
[](https://www.jetbrains.com/ruby/)
|
|
6
6
|
|
|
7
7
|
[](https://github.com/yegor256/threads/actions/workflows/rake.yml)
|
|
8
|
-
[](
|
|
8
|
+
[](https://badge.fury.io/rb/threads)
|
|
9
9
|
[](https://codeclimate.com/github/yegor256/threads/maintainability)
|
|
10
|
-
[](https://rubydoc.info/github/yegor256/threads/master/frames)
|
|
11
11
|
[](https://codecov.io/github/yegor256/threads?branch=master)
|
|
12
12
|
[](https://hitsofcode.com/view/github/yegor256/threads)
|
|
13
13
|
|
|
@@ -63,7 +63,7 @@ That's it.
|
|
|
63
63
|
|
|
64
64
|
Read
|
|
65
65
|
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
|
66
|
-
Make sure
|
|
66
|
+
Make sure your build is green before you contribute
|
|
67
67
|
your pull request. You will need to have
|
|
68
68
|
[Ruby](https://www.ruby-lang.org/en/) 2.3+ and
|
|
69
69
|
[Bundler](https://bundler.io/) installed. Then:
|
data/REUSE.toml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
version = 1
|
|
5
|
+
[[annotations]]
|
|
6
|
+
path = [
|
|
7
|
+
".DS_Store",
|
|
8
|
+
".gitattributes",
|
|
9
|
+
".gitignore",
|
|
10
|
+
".pdd",
|
|
11
|
+
"**.json",
|
|
12
|
+
"**.md",
|
|
13
|
+
"**.png",
|
|
14
|
+
"**.svg",
|
|
15
|
+
"**.txt",
|
|
16
|
+
"**/.DS_Store",
|
|
17
|
+
"**/.gitignore",
|
|
18
|
+
"**/.pdd",
|
|
19
|
+
"**/*.csv",
|
|
20
|
+
"**/*.jpg",
|
|
21
|
+
"**/*.json",
|
|
22
|
+
"**/*.md",
|
|
23
|
+
"**/*.pdf",
|
|
24
|
+
"**/*.png",
|
|
25
|
+
"**/*.svg",
|
|
26
|
+
"**/*.txt",
|
|
27
|
+
"**/*.vm",
|
|
28
|
+
"**/CNAME",
|
|
29
|
+
"**/Gemfile.lock",
|
|
30
|
+
"Gemfile.lock",
|
|
31
|
+
"README.md",
|
|
32
|
+
"renovate.json",
|
|
33
|
+
]
|
|
34
|
+
precedence = "override"
|
|
35
|
+
SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
|
|
36
|
+
SPDX-License-Identifier = "MIT"
|
data/Rakefile
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'rubygems'
|
|
24
7
|
require 'rake'
|
|
@@ -48,11 +31,11 @@ require 'yard'
|
|
|
48
31
|
desc 'Build Yard documentation'
|
|
49
32
|
YARD::Rake::YardocTask.new do |t|
|
|
50
33
|
t.files = ['lib/**/*.rb']
|
|
34
|
+
t.options = ['--fail-on-warning']
|
|
51
35
|
end
|
|
52
36
|
|
|
53
37
|
require 'rubocop/rake_task'
|
|
54
38
|
desc 'Run RuboCop on all directories'
|
|
55
39
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
56
40
|
task.fail_on_error = true
|
|
57
|
-
task.requires << 'rubocop-rspec'
|
|
58
41
|
end
|
data/lib/threads.rb
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'concurrent'
|
|
26
7
|
require 'backtrace'
|
|
@@ -39,27 +20,60 @@ require 'backtrace'
|
|
|
39
20
|
# thread.
|
|
40
21
|
#
|
|
41
22
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
42
|
-
# Copyright:: Copyright (c) 2018-
|
|
23
|
+
# Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
|
|
43
24
|
# License:: MIT
|
|
44
25
|
class Threads
|
|
45
26
|
# Constructor.
|
|
46
27
|
#
|
|
47
28
|
# @param [Number] total How many threads to run
|
|
48
29
|
# @param [Logger] log Where to print output
|
|
49
|
-
|
|
30
|
+
# @param [Number] task_timeout How many seconds to wait for all tasks to finish
|
|
31
|
+
# @param [Number] shutdown_timeout How many seconds to wait for the thread pool to shut down
|
|
32
|
+
def initialize(total = Concurrent.processor_count * 8, log: $stdout, task_timeout: 10, shutdown_timeout: 30)
|
|
50
33
|
raise "Total can't be nil" if total.nil?
|
|
51
34
|
raise "Total can't be negative or zero: #{total}" unless total.positive?
|
|
52
35
|
@total = total
|
|
53
36
|
raise "Log can't be nil" if log.nil?
|
|
54
37
|
@log = log
|
|
38
|
+
validate('task_timeout', task_timeout)
|
|
39
|
+
@task_timeout = task_timeout
|
|
40
|
+
validate('shutdown_timeout', shutdown_timeout)
|
|
41
|
+
@shutdown_timeout = shutdown_timeout
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Validate a timeout value.
|
|
45
|
+
# @param [String] label Label to use in the error message
|
|
46
|
+
# @param [Number] timeout Timeout value to validate
|
|
47
|
+
def validate(label, timeout)
|
|
48
|
+
raise "#{label} can't be nil" if timeout.nil?
|
|
49
|
+
raise "#{label} can't be negative or zero: #{timeout}" unless timeout.positive?
|
|
55
50
|
end
|
|
56
51
|
|
|
57
52
|
# Run them all and assert that all of them finished successfully.
|
|
58
53
|
#
|
|
54
|
+
# For example, test a counter for thread safety:
|
|
55
|
+
#
|
|
56
|
+
# counter = 0
|
|
57
|
+
# mutex = Mutex.new
|
|
58
|
+
# Threads.new(10).assert do |t|
|
|
59
|
+
# mutex.synchronize { counter += 1 }
|
|
60
|
+
# end
|
|
61
|
+
# puts "Final counter value: #{counter}"
|
|
62
|
+
#
|
|
63
|
+
# You can also access the repetition index:
|
|
64
|
+
#
|
|
65
|
+
# Threads.new(4).assert(100) do |t, r|
|
|
66
|
+
# puts "Thread #{t}, repetition #{r}"
|
|
67
|
+
# end
|
|
68
|
+
#
|
|
59
69
|
# @param [Number] reps How many times to repeat the testing cycle
|
|
70
|
+
# @param [Number] task_timeout How many seconds to wait for all tasks to finish
|
|
71
|
+
# @param [Number] shutdown_timeout How many seconds to wait for the thread pool to shut down
|
|
60
72
|
# @return nil
|
|
61
|
-
def assert(reps = @total)
|
|
73
|
+
def assert(reps = @total, task_timeout: @task_timeout, shutdown_timeout: @shutdown_timeout)
|
|
62
74
|
raise "Repetition counter #{reps} can't be smaller than #{@total}" if reps < @total
|
|
75
|
+
validate('task_timeout', task_timeout)
|
|
76
|
+
validate('shutdown_timeout', shutdown_timeout)
|
|
63
77
|
done = Concurrent::AtomicFixnum.new
|
|
64
78
|
rep = Concurrent::AtomicFixnum.new
|
|
65
79
|
pool = Concurrent::FixedThreadPool.new(@total)
|
|
@@ -87,9 +101,9 @@ class Threads
|
|
|
87
101
|
end
|
|
88
102
|
end
|
|
89
103
|
latch.count_down
|
|
90
|
-
finish.wait(
|
|
104
|
+
finish.wait(task_timeout)
|
|
91
105
|
pool.shutdown
|
|
92
|
-
raise "Can't stop the pool" unless pool.wait_for_termination(
|
|
106
|
+
raise "Can't stop the pool" unless pool.wait_for_termination(shutdown_timeout)
|
|
93
107
|
return if done.value == @total
|
|
94
108
|
raise "Only #{done.value} out of #{@total} threads completed successfully"
|
|
95
109
|
end
|
data/logo.svg
CHANGED
data/threads.gemspec
CHANGED
|
@@ -1,40 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# (
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
24
5
|
|
|
25
6
|
require 'English'
|
|
26
7
|
Gem::Specification.new do |s|
|
|
27
8
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
28
9
|
s.required_ruby_version = '>=2.3'
|
|
29
10
|
s.name = 'threads'
|
|
30
|
-
s.version = '0.
|
|
11
|
+
s.version = '0.5.0'
|
|
31
12
|
s.license = 'MIT'
|
|
32
13
|
s.summary = 'Test threads'
|
|
33
|
-
s.description = '
|
|
14
|
+
s.description = 'Ruby Gem to test a piece of code in concurrent threads'
|
|
34
15
|
s.authors = ['Yegor Bugayenko']
|
|
35
16
|
s.email = 'yegor256@gmail.com'
|
|
36
|
-
s.homepage = '
|
|
37
|
-
s.files = `git ls-files`.split($RS)
|
|
17
|
+
s.homepage = 'https://github.com/yegor256/threads'
|
|
18
|
+
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
38
19
|
s.rdoc_options = ['--charset=UTF-8']
|
|
39
20
|
s.extra_rdoc_files = ['README.md']
|
|
40
21
|
s.add_dependency 'backtrace', '~>0'
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: threads
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: backtrace
|
|
@@ -38,42 +37,28 @@ dependencies:
|
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '1.0'
|
|
41
|
-
description:
|
|
40
|
+
description: Ruby Gem to test a piece of code in concurrent threads
|
|
42
41
|
email: yegor256@gmail.com
|
|
43
42
|
executables: []
|
|
44
43
|
extensions: []
|
|
45
44
|
extra_rdoc_files:
|
|
46
45
|
- README.md
|
|
47
46
|
files:
|
|
48
|
-
- ".0pdd.yml"
|
|
49
|
-
- ".github/workflows/actionlint.yml"
|
|
50
|
-
- ".github/workflows/codecov.yml"
|
|
51
|
-
- ".github/workflows/copyrights.yml"
|
|
52
|
-
- ".github/workflows/markdown-lint.yml"
|
|
53
|
-
- ".github/workflows/pdd.yml"
|
|
54
|
-
- ".github/workflows/rake.yml"
|
|
55
|
-
- ".github/workflows/xcop.yml"
|
|
56
|
-
- ".github/workflows/yamllint.yml"
|
|
57
|
-
- ".gitignore"
|
|
58
|
-
- ".pdd"
|
|
59
|
-
- ".rubocop.yml"
|
|
60
|
-
- ".rultor.yml"
|
|
61
47
|
- Gemfile
|
|
48
|
+
- Gemfile.lock
|
|
62
49
|
- LICENSE.txt
|
|
50
|
+
- LICENSES/MIT.txt
|
|
63
51
|
- README.md
|
|
52
|
+
- REUSE.toml
|
|
64
53
|
- Rakefile
|
|
65
54
|
- lib/threads.rb
|
|
66
55
|
- logo.svg
|
|
67
|
-
- renovate.json
|
|
68
|
-
- test/test__helper.rb
|
|
69
|
-
- test/test_threads.rb
|
|
70
56
|
- threads.gemspec
|
|
71
|
-
homepage:
|
|
57
|
+
homepage: https://github.com/yegor256/threads
|
|
72
58
|
licenses:
|
|
73
59
|
- MIT
|
|
74
60
|
metadata:
|
|
75
61
|
rubygems_mfa_required: 'true'
|
|
76
|
-
post_install_message:
|
|
77
62
|
rdoc_options:
|
|
78
63
|
- "--charset=UTF-8"
|
|
79
64
|
require_paths:
|
|
@@ -89,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
89
74
|
- !ruby/object:Gem::Version
|
|
90
75
|
version: '0'
|
|
91
76
|
requirements: []
|
|
92
|
-
rubygems_version: 3.
|
|
93
|
-
signing_key:
|
|
77
|
+
rubygems_version: 3.6.9
|
|
94
78
|
specification_version: 4
|
|
95
79
|
summary: Test threads
|
|
96
80
|
test_files: []
|
data/.0pdd.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
errors:
|
|
24
|
-
- yegor256@gmail.com
|
|
25
|
-
tags:
|
|
26
|
-
- pdd
|
|
27
|
-
- bug
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: actionlint
|
|
24
|
-
'on':
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
pull_request:
|
|
29
|
-
branches:
|
|
30
|
-
- master
|
|
31
|
-
jobs:
|
|
32
|
-
actionlint:
|
|
33
|
-
runs-on: ubuntu-24.04
|
|
34
|
-
steps:
|
|
35
|
-
- uses: actions/checkout@v4
|
|
36
|
-
- name: Download actionlint
|
|
37
|
-
id: get_actionlint
|
|
38
|
-
# yamllint disable-line rule:line-length
|
|
39
|
-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
40
|
-
shell: bash
|
|
41
|
-
- name: Check workflow files
|
|
42
|
-
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
|
43
|
-
shell: bash
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: codecov
|
|
24
|
-
on:
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
jobs:
|
|
29
|
-
codecov:
|
|
30
|
-
runs-on: ubuntu-24.04
|
|
31
|
-
steps:
|
|
32
|
-
- uses: actions/checkout@v4
|
|
33
|
-
- uses: ruby/setup-ruby@v1
|
|
34
|
-
with:
|
|
35
|
-
ruby-version: 2.7
|
|
36
|
-
- run: bundle update
|
|
37
|
-
- run: bundle exec rake
|
|
38
|
-
- uses: codecov/codecov-action@v5
|
|
39
|
-
with:
|
|
40
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: copyrights
|
|
24
|
-
'on':
|
|
25
|
-
push:
|
|
26
|
-
pull_request:
|
|
27
|
-
jobs:
|
|
28
|
-
copyrights:
|
|
29
|
-
runs-on: ubuntu-24.04
|
|
30
|
-
steps:
|
|
31
|
-
- uses: actions/checkout@v4
|
|
32
|
-
- uses: yegor256/copyrights-action@0.0.8
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: markdown-lint
|
|
24
|
-
'on':
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
pull_request:
|
|
29
|
-
branches:
|
|
30
|
-
- master
|
|
31
|
-
paths-ignore: ['paper/**', 'sandbox/**']
|
|
32
|
-
concurrency:
|
|
33
|
-
group: markdown-lint-${{ github.ref }}
|
|
34
|
-
cancel-in-progress: true
|
|
35
|
-
jobs:
|
|
36
|
-
markdown-lint:
|
|
37
|
-
runs-on: ubuntu-24.04
|
|
38
|
-
steps:
|
|
39
|
-
- uses: actions/checkout@v4
|
|
40
|
-
- uses: articulate/actions-markdownlint@v1
|
data/.github/workflows/pdd.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: pdd
|
|
24
|
-
on:
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
pull_request:
|
|
29
|
-
branches:
|
|
30
|
-
- master
|
|
31
|
-
jobs:
|
|
32
|
-
pdd:
|
|
33
|
-
runs-on: ubuntu-24.04
|
|
34
|
-
steps:
|
|
35
|
-
- uses: actions/checkout@v4
|
|
36
|
-
- uses: volodya-lombrozo/pdd-action@master
|
data/.github/workflows/rake.yml
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: rake
|
|
24
|
-
on:
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
pull_request:
|
|
29
|
-
branches:
|
|
30
|
-
- master
|
|
31
|
-
jobs:
|
|
32
|
-
test:
|
|
33
|
-
name: test
|
|
34
|
-
strategy:
|
|
35
|
-
matrix:
|
|
36
|
-
os: [ubuntu-24.04, macos-15]
|
|
37
|
-
ruby: [2.7, 3.3]
|
|
38
|
-
runs-on: ${{ matrix.os }}
|
|
39
|
-
steps:
|
|
40
|
-
- uses: actions/checkout@v4
|
|
41
|
-
- uses: ruby/setup-ruby@v1
|
|
42
|
-
with:
|
|
43
|
-
ruby-version: ${{ matrix.ruby }}
|
|
44
|
-
- run: bundle update
|
|
45
|
-
- run: bundle exec rake
|
data/.github/workflows/xcop.yml
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: xcop
|
|
24
|
-
on:
|
|
25
|
-
push:
|
|
26
|
-
pull_request:
|
|
27
|
-
jobs:
|
|
28
|
-
xcop:
|
|
29
|
-
runs-on: ubuntu-24.04
|
|
30
|
-
steps:
|
|
31
|
-
- uses: actions/checkout@v4
|
|
32
|
-
- uses: g4s8/xcop-action@master
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
name: yamllint
|
|
24
|
-
'on':
|
|
25
|
-
push:
|
|
26
|
-
branches:
|
|
27
|
-
- master
|
|
28
|
-
pull_request:
|
|
29
|
-
branches:
|
|
30
|
-
- master
|
|
31
|
-
jobs:
|
|
32
|
-
yamllint:
|
|
33
|
-
runs-on: ubuntu-24.04
|
|
34
|
-
steps:
|
|
35
|
-
- uses: actions/checkout@v4
|
|
36
|
-
- uses: ibiqlik/action-yamllint@v3
|
data/.gitignore
DELETED
data/.pdd
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
AllCops:
|
|
24
|
-
DisplayCopNames: true
|
|
25
|
-
TargetRubyVersion: 2.3.3
|
|
26
|
-
NewCops: enable
|
|
27
|
-
SuggestExtensions: false
|
|
28
|
-
|
|
29
|
-
Metrics/AbcSize:
|
|
30
|
-
Max: 50
|
|
31
|
-
Metrics/MethodLength:
|
|
32
|
-
Max: 50
|
|
33
|
-
Metrics/BlockLength:
|
|
34
|
-
Max: 30
|
|
35
|
-
Layout/EmptyLineAfterGuardClause:
|
|
36
|
-
Enabled: false
|
data/.rultor.yml
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# (The MIT License)
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
22
|
-
---
|
|
23
|
-
docker:
|
|
24
|
-
image: yegor256/rultor-ruby
|
|
25
|
-
assets:
|
|
26
|
-
rubygems.yml: yegor256/home#assets/rubygems.yml
|
|
27
|
-
install: |-
|
|
28
|
-
sudo chown -R "$(whoami)" /usr/local/rvm
|
|
29
|
-
bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
|
30
|
-
release:
|
|
31
|
-
script: |-
|
|
32
|
-
bundle exec rake
|
|
33
|
-
rm -rf *.gem
|
|
34
|
-
sed -i "s/0\.0\.0/${tag}/g" threads.gemspec
|
|
35
|
-
git add threads.gemspec
|
|
36
|
-
git commit -m "Version set to ${tag}"
|
|
37
|
-
gem build threads.gemspec
|
|
38
|
-
chmod 0600 ../rubygems.yml
|
|
39
|
-
gem push *.gem --config-file ../rubygems.yml
|
|
40
|
-
merge:
|
|
41
|
-
script: |-
|
|
42
|
-
bundle exec rake
|
data/renovate.json
DELETED
data/test/test__helper.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# (The MIT License)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
24
|
-
|
|
25
|
-
$stdout.sync = true
|
|
26
|
-
|
|
27
|
-
require 'simplecov'
|
|
28
|
-
SimpleCov.start
|
data/test/test_threads.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# (The MIT License)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (c) 2018-2024 Yegor Bugayenko
|
|
6
|
-
#
|
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
# SOFTWARE.
|
|
24
|
-
|
|
25
|
-
require 'minitest/autorun'
|
|
26
|
-
require 'concurrent'
|
|
27
|
-
require_relative '../lib/threads'
|
|
28
|
-
|
|
29
|
-
# Threads test.
|
|
30
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
31
|
-
# Copyright:: Copyright (c) 2018-2024 Yegor Bugayenko
|
|
32
|
-
# License:: MIT
|
|
33
|
-
class ThreadsTest < Minitest::Test
|
|
34
|
-
def test_multiple_threads
|
|
35
|
-
done = Concurrent::AtomicFixnum.new
|
|
36
|
-
Threads.new(10).assert do
|
|
37
|
-
done.increment
|
|
38
|
-
end
|
|
39
|
-
assert_equal(10, done.value)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_multiple_threads_with_cap
|
|
43
|
-
done = Concurrent::AtomicFixnum.new
|
|
44
|
-
Threads.new(3).assert(20) do
|
|
45
|
-
done.increment
|
|
46
|
-
end
|
|
47
|
-
assert_equal(20, done.value)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_slow_threads
|
|
51
|
-
done = Concurrent::AtomicFixnum.new
|
|
52
|
-
Threads.new(3).assert(20) do
|
|
53
|
-
sleep(0.1)
|
|
54
|
-
done.increment
|
|
55
|
-
end
|
|
56
|
-
assert_equal(20, done.value)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_multiple_threads_with_errors
|
|
60
|
-
log = FakeLog.new
|
|
61
|
-
assert_raises do
|
|
62
|
-
Threads.new(3, log: log).assert(20) do
|
|
63
|
-
this_code_is_broken
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
assert_equal(3, log.logs.count)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class FakeLog
|
|
70
|
-
attr_reader :logs
|
|
71
|
-
|
|
72
|
-
def initialize
|
|
73
|
-
@logs = []
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def error(msg)
|
|
77
|
-
@logs << msg
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|