async-pool 0.3.7 → 0.3.10
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
- checksums.yaml.gz.sig +0 -0
- data/lib/async/pool/controller.rb +19 -19
- data/lib/async/pool/resource.rb +4 -0
- data/lib/async/pool/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +36 -34
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cfb2bc4d32b54e48faffdd3c42b28afa1841408ba0ebf175d9ca051ffd6e694
|
4
|
+
data.tar.gz: 4cf7f16990280ac4e7fb1b7d15759c2b372979a36c27b6ad437a0c006335bf83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cadc28962a1809997883f6f73c87701e4734582ed3fbfcb925a5777e35032cd2d89b1fa3ef71ce6719f8280c08c538e3460b72eea268cd30be3394635cf32606
|
7
|
+
data.tar.gz: abab1246d90ccc1663b13bcd6bed568cc672a9b211ac26ce8aeda5249badec6a4971c519689d03170e4a92a72b1669cc19cb7b108a5504bfcadaaecc80650a74
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -31,7 +31,7 @@ module Async
|
|
31
31
|
self.new(block, **options)
|
32
32
|
end
|
33
33
|
|
34
|
-
def initialize(constructor, limit: nil)
|
34
|
+
def initialize(constructor, limit: nil, concurrency: nil)
|
35
35
|
# All available resources:
|
36
36
|
@resources = {}
|
37
37
|
|
@@ -44,7 +44,15 @@ module Async
|
|
44
44
|
@limit = limit
|
45
45
|
|
46
46
|
@constructor = constructor
|
47
|
-
|
47
|
+
|
48
|
+
# Set the concurrency to be the same as the limit for maximum performance:
|
49
|
+
if limit
|
50
|
+
concurrency ||= limit
|
51
|
+
else
|
52
|
+
concurrency ||= 1
|
53
|
+
end
|
54
|
+
|
55
|
+
@guard = Async::Semaphore.new(concurrency)
|
48
56
|
|
49
57
|
@gardener = nil
|
50
58
|
end
|
@@ -98,12 +106,14 @@ module Async
|
|
98
106
|
|
99
107
|
# Make the resource resources and let waiting tasks know that there is something resources.
|
100
108
|
def release(resource)
|
109
|
+
processed = false
|
110
|
+
|
101
111
|
# A resource that is not good should also not be reusable.
|
102
112
|
if resource.reusable?
|
103
|
-
reuse(resource)
|
104
|
-
else
|
105
|
-
retire(resource)
|
113
|
+
processed = reuse(resource)
|
106
114
|
end
|
115
|
+
ensure
|
116
|
+
retire(resource) unless processed
|
107
117
|
end
|
108
118
|
|
109
119
|
def close
|
@@ -164,6 +174,8 @@ module Async
|
|
164
174
|
resource.close
|
165
175
|
|
166
176
|
@notification.signal
|
177
|
+
|
178
|
+
return true
|
167
179
|
end
|
168
180
|
|
169
181
|
protected
|
@@ -199,13 +211,6 @@ module Async
|
|
199
211
|
@resources.count{|resource, usage| usage == 0}
|
200
212
|
end
|
201
213
|
|
202
|
-
# @returns [Boolean] Whether the number of available resources is excessive and we should retire some.
|
203
|
-
def overflowing?
|
204
|
-
if @resources.any?
|
205
|
-
(self.free.to_f / @resources.size) > 0.5
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
214
|
def reuse(resource)
|
210
215
|
Console.logger.debug(self) {"Reuse #{resource}"}
|
211
216
|
usage = @resources[resource]
|
@@ -214,13 +219,6 @@ module Async
|
|
214
219
|
raise "Trying to reuse unacquired resource: #{resource}!"
|
215
220
|
end
|
216
221
|
|
217
|
-
# We retire resources when adding to the @available list would overflow our pool:
|
218
|
-
if usage == 1
|
219
|
-
if overflowing?
|
220
|
-
return retire(resource)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
222
|
# If the resource was fully utilized, it now becomes available:
|
225
223
|
if usage == resource.concurrency
|
226
224
|
@available.push(resource)
|
@@ -229,6 +227,8 @@ module Async
|
|
229
227
|
@resources[resource] = usage - 1
|
230
228
|
|
231
229
|
@notification.signal
|
230
|
+
|
231
|
+
return true
|
232
232
|
end
|
233
233
|
|
234
234
|
def wait_for_resource
|
data/lib/async/pool/resource.rb
CHANGED
data/lib/async/pool/version.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,27 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Olle Jonsson
|
9
|
+
- Simon Perepelitsa
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
12
|
+
cert_chain:
|
13
|
+
- |
|
14
|
+
-----BEGIN CERTIFICATE-----
|
15
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
16
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
17
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
18
|
+
aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
|
19
|
+
AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
|
20
|
+
xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
|
21
|
+
eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
|
22
|
+
L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
|
23
|
+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FbKrRsIQ24qDbNJRtOpE
|
38
|
+
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
39
|
+
HiLJ8VOFx6w=
|
40
|
+
-----END CERTIFICATE-----
|
41
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
42
|
dependencies:
|
13
43
|
- !ruby/object:Gem::Dependency
|
14
44
|
name: async
|
15
45
|
requirement: !ruby/object:Gem::Requirement
|
16
46
|
requirements:
|
17
|
-
- - "
|
47
|
+
- - ">="
|
18
48
|
- !ruby/object:Gem::Version
|
19
49
|
version: '1.25'
|
20
50
|
type: :runtime
|
21
51
|
prerelease: false
|
22
52
|
version_requirements: !ruby/object:Gem::Requirement
|
23
53
|
requirements:
|
24
|
-
- - "
|
54
|
+
- - ">="
|
25
55
|
- !ruby/object:Gem::Version
|
26
56
|
version: '1.25'
|
27
57
|
- !ruby/object:Gem::Dependency
|
@@ -38,34 +68,6 @@ dependencies:
|
|
38
68
|
- - "~>"
|
39
69
|
- !ruby/object:Gem::Version
|
40
70
|
version: '1.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bake-bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bake-modernize
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
71
|
- !ruby/object:Gem::Dependency
|
70
72
|
name: bundler
|
71
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
140
|
- !ruby/object:Gem::Version
|
139
141
|
version: '0'
|
140
142
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
142
144
|
signing_key:
|
143
145
|
specification_version: 4
|
144
146
|
summary: A singleplex and multiplex resource pool for implementing robust clients.
|
metadata.gz.sig
ADDED
Binary file
|