async-pool 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/pool/controller.rb +10 -16
- data/lib/async/pool/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -2
- 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
CHANGED
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
|
@@ -203,13 +211,6 @@ module Async
|
|
203
211
|
@resources.count{|resource, usage| usage == 0}
|
204
212
|
end
|
205
213
|
|
206
|
-
# @returns [Boolean] Whether the number of available resources is excessive and we should retire some.
|
207
|
-
def overflowing?
|
208
|
-
if @resources.any?
|
209
|
-
(self.free.to_f / @resources.size) > 0.5
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
214
|
def reuse(resource)
|
214
215
|
Console.logger.debug(self) {"Reuse #{resource}"}
|
215
216
|
usage = @resources[resource]
|
@@ -218,13 +219,6 @@ module Async
|
|
218
219
|
raise "Trying to reuse unacquired resource: #{resource}!"
|
219
220
|
end
|
220
221
|
|
221
|
-
# We retire resources when adding to the @available list would overflow our pool:
|
222
|
-
if usage == 1
|
223
|
-
if overflowing?
|
224
|
-
return retire(resource)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
222
|
# If the resource was fully utilized, it now becomes available:
|
229
223
|
if usage == resource.concurrency
|
230
224
|
@available.push(resource)
|
data/lib/async/pool/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,12 @@
|
|
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
12
|
cert_chain:
|
@@ -36,7 +38,7 @@ cert_chain:
|
|
36
38
|
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
37
39
|
HiLJ8VOFx6w=
|
38
40
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
41
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
40
42
|
dependencies:
|
41
43
|
- !ruby/object:Gem::Dependency
|
42
44
|
name: async
|
metadata.gz.sig
CHANGED
Binary file
|