async 1.30.3 → 1.31.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/async/semaphore.rb +19 -0
- data/lib/async/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54f8b2dedcd29cf6a5d5c19b9b6ef11762cac77156439930b29d414e45bb6d4
|
4
|
+
data.tar.gz: c420baf542fe9992737ac9d8594cd3f88bb7764904113d801aa891ec328558ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4f467f2d8f2bde924e29636d8d0689509acfd1d463825173d03aa75b4235847db43c7fc6a9d4a10e18a444d542332218e1f3a9a0bb471d1a918bb411dd7a73
|
7
|
+
data.tar.gz: 95affc48630a0b2e83457e58024dfa89c091060b1047151849e30bce3a493a5e5ffaa06e824086df347dfb862f66cf834a08f3609d4b718eb7e3c74157bc1ad9
|
data/lib/async/semaphore.rb
CHANGED
@@ -40,6 +40,25 @@ module Async
|
|
40
40
|
# The tasks waiting on this semaphore.
|
41
41
|
attr :waiting
|
42
42
|
|
43
|
+
# Allow setting the limit. This is useful for cases where the semaphore is used to limit the number of concurrent tasks, but the number of tasks is not known in advance or needs to be modified.
|
44
|
+
#
|
45
|
+
# On increasing the limit, some tasks may be immediately resumed. On decreasing the limit, some tasks may execute until the count is < than the limit.
|
46
|
+
#
|
47
|
+
# @parameter limit [Integer] The new limit.
|
48
|
+
def limit= limit
|
49
|
+
difference = limit - @limit
|
50
|
+
@limit = limit
|
51
|
+
|
52
|
+
# We can't suspend
|
53
|
+
if difference > 0
|
54
|
+
difference.times do
|
55
|
+
break unless fiber = @waiting.shift
|
56
|
+
|
57
|
+
fiber.resume
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
43
62
|
# Is the semaphore currently acquired?
|
44
63
|
def empty?
|
45
64
|
@count.zero?
|
data/lib/async/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: console
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.4.7
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: A concurrency framework for Ruby.
|