async-pool 0.3.8 → 0.3.11
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 +15 -19
- data/lib/async/pool/version.rb +1 -1
- data.tar.gz.sig +1 -0
- metadata +35 -32
- 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: 2b18ddc4cbc74698b642f3196160fe5a59b93ae0484d25a84da43cd1b2a9c90d
|
4
|
+
data.tar.gz: 668b970b18cae244620c289909f72d9fcfe1bef70771ddaa9a9a251615fbfd08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb6353d6ca63c11516d67183f722ff50e78428a86112d7e6fbb097f3706b02cbefa0768e0c38de64f662882ee70bdd8555f9c3d9654810a88fecf7284213495b
|
7
|
+
data.tar.gz: 211e98500aa73c4a1fa6ca0bc944f39e859c3383e08b323a396b0fbd245239fe36804482f9d896aeb555097c8b79eecd4df393f643905964eb136a6a0a98c742
|
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,14 +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)
|
101
|
-
|
109
|
+
processed = false
|
102
110
|
|
103
111
|
# A resource that is not good should also not be reusable.
|
104
112
|
if resource.reusable?
|
105
|
-
|
113
|
+
processed = reuse(resource)
|
106
114
|
end
|
107
115
|
ensure
|
108
|
-
retire(resource) unless
|
116
|
+
retire(resource) unless processed
|
109
117
|
end
|
110
118
|
|
111
119
|
def close
|
@@ -166,6 +174,8 @@ module Async
|
|
166
174
|
resource.close
|
167
175
|
|
168
176
|
@notification.signal
|
177
|
+
|
178
|
+
return true
|
169
179
|
end
|
170
180
|
|
171
181
|
protected
|
@@ -201,13 +211,6 @@ module Async
|
|
201
211
|
@resources.count{|resource, usage| usage == 0}
|
202
212
|
end
|
203
213
|
|
204
|
-
# @returns [Boolean] Whether the number of available resources is excessive and we should retire some.
|
205
|
-
def overflowing?
|
206
|
-
if @resources.any?
|
207
|
-
(self.free.to_f / @resources.size) > 0.5
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
214
|
def reuse(resource)
|
212
215
|
Console.logger.debug(self) {"Reuse #{resource}"}
|
213
216
|
usage = @resources[resource]
|
@@ -216,13 +219,6 @@ module Async
|
|
216
219
|
raise "Trying to reuse unacquired resource: #{resource}!"
|
217
220
|
end
|
218
221
|
|
219
|
-
# We retire resources when adding to the @available list would overflow our pool:
|
220
|
-
if usage == 1
|
221
|
-
if overflowing?
|
222
|
-
return retire(resource)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
222
|
# If the resource was fully utilized, it now becomes available:
|
227
223
|
if usage == resource.concurrency
|
228
224
|
@available.push(resource)
|
data/lib/async/pool/version.rb
CHANGED
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
s��ʗ��G8���EDʘ�V��l�#؟(����{���2:�������o�s3�{Xa��CrMmմ ����W9�>,�?�� �C
|
metadata
CHANGED
@@ -1,14 +1,45 @@
|
|
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.11
|
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
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
16
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
17
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
18
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
19
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
20
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
21
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
22
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
23
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
24
|
+
e5AUKRwUuvaUaumAKgPH+4E4oi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yaxt
|
39
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
40
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
41
|
+
-----END CERTIFICATE-----
|
42
|
+
date: 2022-08-17 00:00:00.000000000 Z
|
12
43
|
dependencies:
|
13
44
|
- !ruby/object:Gem::Dependency
|
14
45
|
name: async
|
@@ -38,34 +69,6 @@ dependencies:
|
|
38
69
|
- - "~>"
|
39
70
|
- !ruby/object:Gem::Version
|
40
71
|
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
72
|
- !ruby/object:Gem::Dependency
|
70
73
|
name: bundler
|
71
74
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
141
|
- !ruby/object:Gem::Version
|
139
142
|
version: '0'
|
140
143
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.1.6
|
142
145
|
signing_key:
|
143
146
|
specification_version: 4
|
144
147
|
summary: A singleplex and multiplex resource pool for implementing robust clients.
|
metadata.gz.sig
ADDED
Binary file
|