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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63f0054e2d8ce94ab52e1186939e06ae2045edd757ba0ba1e0f0eca0f1ec1f80
4
- data.tar.gz: 10d52bf1f00b7e8062b8ee3bbd612c79d0db07e28fa08e6273814eb686861178
3
+ metadata.gz: 5cfb2bc4d32b54e48faffdd3c42b28afa1841408ba0ebf175d9ca051ffd6e694
4
+ data.tar.gz: 4cf7f16990280ac4e7fb1b7d15759c2b372979a36c27b6ad437a0c006335bf83
5
5
  SHA512:
6
- metadata.gz: 3239399837876e2eb1fa00106eafd1d1e8c78c8eceb840fa5c7a694e4d819931803fd4ea8cc1cd6acc490071d379638463eaee8884d46d721488316e60d3cd48
7
- data.tar.gz: 005f0036c7153b774fd31806f206a69a35b394f99cb899498939dc69b4e2e520d34db342c74ff0c7a6b5345ca4db91f0f68bb269dfc9373b3a55236df08d5934
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
- @guard = Async::Semaphore.new(1)
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)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Pool
23
- VERSION = "0.3.9"
23
+ VERSION = "0.3.10"
24
24
  end
25
25
  end
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.9
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: 2021-09-30 00:00:00.000000000 Z
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