tins 1.37.1 → 1.38.0

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
  SHA256:
3
- metadata.gz: 45cdce796cfd7bd217b41dde419d3a3399e6b06a71a3aad809ed1ffd81fee1b6
4
- data.tar.gz: cc3474c0776f6feaa025dedf5ae466bad277de63b9ba34343a43e8c5e281c531
3
+ metadata.gz: 26f2a6faf004d28bc511820eb58835ba4b555481d38b12839b264fde8664b321
4
+ data.tar.gz: 394319369bf23b6afee56aebfe70ebdebe9d4d05ff77181338a754f667921266
5
5
  SHA512:
6
- metadata.gz: 9506088d3c0c744bc706753accf329f2995d20400a43fdc738c31d4965ff66266d2d2143796f2812daa3adefedcdf49281eb0ba209f7b0d474c857ca707c4d82
7
- data.tar.gz: af4c092a1bf371da47fa061565d3fed7a65132231762bfefb566c126137febf4fb212535581928d068ac607beb5cd83a55f338ef345dfcca2a59e443f9ce7a23
6
+ metadata.gz: 6491996c174a13ec0a4b1cbd8c2437e7f7becca98965962a0aa446e7a7bd50f87ef8ebef4ba61dc0c48b38a97a0009ee1b6411a414c42ca53903f97a9e025861
7
+ data.tar.gz: cc785591e2c3efe72b0b70585dd30001bf5d4e6d7ff6b8b1b88c023c7be85bc6cb1ca7262e9b3ace3a009f4eac39ca2b9cf62dea73858bd0dd570292b583c62d
data/CHANGES.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-01-04 v1.38.0
4
+
5
+ * Improved Tins::Limited concurrency handling:
6
+ * Added `execute` method for task submission with a block
7
+ * Changed `process` method to manage thread execution and queue management
8
+ * Introduced `stop` method to signal processing termination
9
+ * Modified test cases in `limited_test.rb` to accommodate new functionality
10
+ * Added `ensure` clause to decrement counter and signal continuation after
11
+ block execution
12
+ * Added support for Ruby **3.4** Alpine image:
13
+ * Updated `.all_images.yml` to include Ruby **3.4**-alpine environment
14
+ * Added `ruby:3.4-alpine` to the list of supported images
15
+ * Now uses **3.4** instead of **3.3**, **3.2**, and **3.1** for ruby versions
16
+
3
17
  ## 2024-12-13 v1.37.1
4
18
 
5
19
  * Renamed `ZERO` and `BINARY` constants to `ZERO_RE` and `BINARY_RE` to avoid
data/lib/tins/limited.rb CHANGED
@@ -16,33 +16,58 @@ module Tins
16
16
  attr_reader :maximum
17
17
 
18
18
  # Execute _maximum_ number of threads in parallel.
19
- def execute
20
- @mutex.synchronize do
19
+ def execute(&block)
20
+ @tasks or raise ArgumentError, "start processing first"
21
+ @tasks << block
22
+ end
23
+
24
+ def process
25
+ @tasks = Queue.new
26
+ @executor = create_executor
27
+ catch :stop do
21
28
  loop do
22
- if @count < @maximum
23
- @count += 1
24
- Thread.new do
25
- @tg.add Thread.current
26
- yield
27
- @mutex.synchronize { @count -= 1 }
28
- @continue.signal
29
- end
30
- return
31
- else
32
- @continue.wait(@mutex)
33
- end
29
+ yield self
34
30
  end
31
+ ensure
32
+ wait until done?
33
+ @executor.kill
35
34
  end
36
35
  end
37
36
 
37
+ def stop
38
+ throw :stop
39
+ end
40
+
41
+ private
42
+
43
+ def done?
44
+ @tasks.empty? && @tg.list.empty?
45
+ end
46
+
38
47
  def wait
39
48
  @tg.list.each(&:join)
40
49
  end
41
50
 
42
- def process
43
- yield self
44
- ensure
45
- wait
51
+ def create_executor
52
+ Thread.new do
53
+ @mutex.synchronize do
54
+ loop do
55
+ if @count < @maximum
56
+ task = @tasks.pop
57
+ @count += 1
58
+ Thread.new do
59
+ @tg.add Thread.current
60
+ task.(Thread.current)
61
+ ensure
62
+ @count -= 1
63
+ @continue.signal
64
+ end
65
+ else
66
+ @continue.wait(@mutex)
67
+ end
68
+ end
69
+ end
70
+ end
46
71
  end
47
72
  end
48
73
  end
data/lib/tins/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.37.1'
3
+ VERSION = '1.38.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -2,36 +2,21 @@ require 'test_helper'
2
2
 
3
3
  module Tins
4
4
  class LimitedTest < Test::Unit::TestCase
5
- def test_limited
6
- count = {}
7
- limited = Tins::Limited.new(5)
8
- 5.times do
9
- limited.execute do
10
- count[Thread.current] = true
11
- sleep 1
12
- end
13
- end
14
- until count.size >= 5
15
- sleep 0.1
16
- end
17
- assert_equal 5, count.keys.uniq.size
18
- assert_equal 5, limited.wait.size
19
- end
20
-
21
- def test_process
5
+ def test_process_with
22
6
  count = {}
23
7
  Tins::Limited.new(5).process do |limited|
24
- 5.times do
8
+ 10.times do
25
9
  limited.execute do
26
10
  count[Thread.current] = true
27
11
  sleep 1
28
12
  end
29
13
  end
30
- until count.size >= 5
14
+ until count.size >= 10
31
15
  sleep 0.1
32
16
  end
33
- assert_equal 5, count.keys.uniq.size
17
+ limited.stop
34
18
  end
19
+ assert_equal 10, count.keys.uniq.size
35
20
  end
36
21
  end
37
22
  end
data/tins.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.37.1 ruby lib
2
+ # stub: tins 1.38.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins".freeze
6
- s.version = "1.37.1".freeze
6
+ s.version = "1.38.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-12-13"
11
+ s.date = "2025-01-07"
12
12
  s.description = "All the stuff that isn't good/big enough for a real library.".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.extra_rdoc_files = ["README.md".freeze, "lib/dslkit.rb".freeze, "lib/dslkit/polite.rb".freeze, "lib/dslkit/rude.rb".freeze, "lib/spruz.rb".freeze, "lib/tins.rb".freeze, "lib/tins/alias.rb".freeze, "lib/tins/annotate.rb".freeze, "lib/tins/ask_and_send.rb".freeze, "lib/tins/attempt.rb".freeze, "lib/tins/bijection.rb".freeze, "lib/tins/case_predicate.rb".freeze, "lib/tins/complete.rb".freeze, "lib/tins/concern.rb".freeze, "lib/tins/count_by.rb".freeze, "lib/tins/date_dummy.rb".freeze, "lib/tins/date_time_dummy.rb".freeze, "lib/tins/deep_const_get.rb".freeze, "lib/tins/deep_dup.rb".freeze, "lib/tins/deprecate.rb".freeze, "lib/tins/dslkit.rb".freeze, "lib/tins/duration.rb".freeze, "lib/tins/expose.rb".freeze, "lib/tins/extract_last_argument_options.rb".freeze, "lib/tins/file_binary.rb".freeze, "lib/tins/find.rb".freeze, "lib/tins/generator.rb".freeze, "lib/tins/go.rb".freeze, "lib/tins/hash_bfs.rb".freeze, "lib/tins/hash_symbolize_keys_recursive.rb".freeze, "lib/tins/hash_union.rb".freeze, "lib/tins/if_predicate.rb".freeze, "lib/tins/implement.rb".freeze, "lib/tins/limited.rb".freeze, "lib/tins/lines_file.rb".freeze, "lib/tins/lru_cache.rb".freeze, "lib/tins/memoize.rb".freeze, "lib/tins/method_description.rb".freeze, "lib/tins/minimize.rb".freeze, "lib/tins/module_group.rb".freeze, "lib/tins/named_set.rb".freeze, "lib/tins/null.rb".freeze, "lib/tins/once.rb".freeze, "lib/tins/p.rb".freeze, "lib/tins/partial_application.rb".freeze, "lib/tins/proc_compose.rb".freeze, "lib/tins/proc_prelude.rb".freeze, "lib/tins/range_plus.rb".freeze, "lib/tins/require_maybe.rb".freeze, "lib/tins/responding.rb".freeze, "lib/tins/secure_write.rb".freeze, "lib/tins/sexy_singleton.rb".freeze, "lib/tins/string_byte_order_mark.rb".freeze, "lib/tins/string_camelize.rb".freeze, "lib/tins/string_underscore.rb".freeze, "lib/tins/string_version.rb".freeze, "lib/tins/subhash.rb".freeze, "lib/tins/temp_io.rb".freeze, "lib/tins/temp_io_enum.rb".freeze, "lib/tins/terminal.rb".freeze, "lib/tins/thread_local.rb".freeze, "lib/tins/time_dummy.rb".freeze, "lib/tins/timed_cache.rb".freeze, "lib/tins/to.rb".freeze, "lib/tins/to_proc.rb".freeze, "lib/tins/token.rb".freeze, "lib/tins/uniq_by.rb".freeze, "lib/tins/unit.rb".freeze, "lib/tins/version.rb".freeze, "lib/tins/write.rb".freeze, "lib/tins/xt.rb".freeze, "lib/tins/xt/annotate.rb".freeze, "lib/tins/xt/ask_and_send.rb".freeze, "lib/tins/xt/attempt.rb".freeze, "lib/tins/xt/blank.rb".freeze, "lib/tins/xt/case_predicate.rb".freeze, "lib/tins/xt/complete.rb".freeze, "lib/tins/xt/concern.rb".freeze, "lib/tins/xt/count_by.rb".freeze, "lib/tins/xt/date_dummy.rb".freeze, "lib/tins/xt/date_time_dummy.rb".freeze, "lib/tins/xt/deep_const_get.rb".freeze, "lib/tins/xt/deep_dup.rb".freeze, "lib/tins/xt/deprecate.rb".freeze, "lib/tins/xt/dslkit.rb".freeze, "lib/tins/xt/expose.rb".freeze, "lib/tins/xt/extract_last_argument_options.rb".freeze, "lib/tins/xt/file_binary.rb".freeze, "lib/tins/xt/full.rb".freeze, "lib/tins/xt/hash_bfs.rb".freeze, "lib/tins/xt/hash_symbolize_keys_recursive.rb".freeze, "lib/tins/xt/hash_union.rb".freeze, "lib/tins/xt/if_predicate.rb".freeze, "lib/tins/xt/implement.rb".freeze, "lib/tins/xt/irb.rb".freeze, "lib/tins/xt/method_description.rb".freeze, "lib/tins/xt/named.rb".freeze, "lib/tins/xt/null.rb".freeze, "lib/tins/xt/p.rb".freeze, "lib/tins/xt/partial_application.rb".freeze, "lib/tins/xt/proc_compose.rb".freeze, "lib/tins/xt/proc_prelude.rb".freeze, "lib/tins/xt/range_plus.rb".freeze, "lib/tins/xt/require_maybe.rb".freeze, "lib/tins/xt/responding.rb".freeze, "lib/tins/xt/secure_write.rb".freeze, "lib/tins/xt/sexy_singleton.rb".freeze, "lib/tins/xt/string.rb".freeze, "lib/tins/xt/string_byte_order_mark.rb".freeze, "lib/tins/xt/string_camelize.rb".freeze, "lib/tins/xt/string_underscore.rb".freeze, "lib/tins/xt/string_version.rb".freeze, "lib/tins/xt/subhash.rb".freeze, "lib/tins/xt/temp_io.rb".freeze, "lib/tins/xt/time_dummy.rb".freeze, "lib/tins/xt/time_freezer.rb".freeze, "lib/tins/xt/to.rb".freeze, "lib/tins/xt/uniq_by.rb".freeze, "lib/tins/xt/write.rb".freeze]
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.licenses = ["MIT".freeze]
18
18
  s.rdoc_options = ["--title".freeze, "Tins - Useful stuff.".freeze, "--main".freeze, "README.md".freeze]
19
19
  s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
20
- s.rubygems_version = "3.5.23".freeze
20
+ s.rubygems_version = "3.6.2".freeze
21
21
  s.summary = "Useful stuff.".freeze
22
22
  s.test_files = ["tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/count_by_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_const_get_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/deprecate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_bfs_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/lru_cache_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/temp_io_test.rb".freeze, "tests/test_helper.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/uniq_by_test.rb".freeze, "tests/unit_test.rb".freeze, "tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/count_by_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_const_get_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/deprecate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_bfs_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/lru_cache_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/temp_io_test.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/uniq_by_test.rb".freeze, "tests/unit_test.rb".freeze]
23
23
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.37.1
4
+ version: 1.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
10
+ date: 2025-01-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: gem_hadar
@@ -463,7 +462,6 @@ homepage: https://github.com/flori/tins
463
462
  licenses:
464
463
  - MIT
465
464
  metadata: {}
466
- post_install_message:
467
465
  rdoc_options:
468
466
  - "--title"
469
467
  - Tins - Useful stuff.
@@ -482,8 +480,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
482
480
  - !ruby/object:Gem::Version
483
481
  version: '0'
484
482
  requirements: []
485
- rubygems_version: 3.5.23
486
- signing_key:
483
+ rubygems_version: 3.6.2
487
484
  specification_version: 4
488
485
  summary: Useful stuff.
489
486
  test_files: