async-pool 0.10.3 → 0.11.1
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 +31 -22
- data/lib/async/pool/version.rb +2 -2
- data/lib/traces/provider/async/pool/controller.rb +5 -5
- data/license.md +2 -1
- data/readme.md +6 -0
- data/releases.md +3 -0
- data.tar.gz.sig +2 -2
- metadata +8 -6
- 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: f51a25e4bec2c50dc1e0a3dd8b58dcea1deec49d964a1e96c2cb4e1ef4f6de91
|
|
4
|
+
data.tar.gz: 7ae894d17e1b977e20910dab375cf898f76051af6b71a165332143550efbb57c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d92167ce83dec22ac8224c10741bef3595884baeef9fb00c31ef71f7a3cced965d642965c4091902567476ba246cd6bfa1c79d16e3bc5e512e5d120184413c93
|
|
7
|
+
data.tar.gz: 44d97c8ea249bbae96158774832e983f88ceb871979b04ab2626aa962705a3e54210e3edf19e235448a623384bc7382b73e854281fa095c18b97c2d73d067918
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2019-
|
|
4
|
+
# Copyright, 2019-2025, by Samuel Williams.
|
|
5
5
|
# Copyright, 2020, by Simon Perepelitsa.
|
|
6
6
|
# Copyright, 2024, by Thomas Morgan.
|
|
7
|
+
# Copyright, 2025, by Jean Boussier.
|
|
7
8
|
|
|
8
9
|
require "console/logger"
|
|
9
10
|
|
|
10
11
|
require "async"
|
|
11
|
-
require "async/notification"
|
|
12
12
|
require "async/semaphore"
|
|
13
13
|
|
|
14
|
+
require "thread"
|
|
15
|
+
|
|
14
16
|
module Async
|
|
15
17
|
module Pool
|
|
16
18
|
# A resource pool controller.
|
|
@@ -46,7 +48,8 @@ module Async
|
|
|
46
48
|
@available = []
|
|
47
49
|
|
|
48
50
|
# Used to signal when a resource has been released:
|
|
49
|
-
@
|
|
51
|
+
@mutex = Thread::Mutex.new
|
|
52
|
+
@condition = Thread::ConditionVariable.new
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# @attribute [Proc] The constructor used to create new resources.
|
|
@@ -123,8 +126,23 @@ module Async
|
|
|
123
126
|
end
|
|
124
127
|
|
|
125
128
|
# Wait until a pool resource has been freed.
|
|
129
|
+
# @deprecated Use {wait_until_free} instead.
|
|
126
130
|
def wait
|
|
127
|
-
@
|
|
131
|
+
@mutex.synchronize do
|
|
132
|
+
@condition.wait(@mutex)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Wait until the pool is not busy (no resources in use).
|
|
137
|
+
def wait_until_free
|
|
138
|
+
@mutex.synchronize do
|
|
139
|
+
if busy?
|
|
140
|
+
yield self if block_given?
|
|
141
|
+
|
|
142
|
+
# Wait until the pool is not busy:
|
|
143
|
+
@condition.wait(@mutex) while busy?
|
|
144
|
+
end
|
|
145
|
+
end
|
|
128
146
|
end
|
|
129
147
|
|
|
130
148
|
# Whether the pool is empty.
|
|
@@ -214,13 +232,13 @@ module Async
|
|
|
214
232
|
|
|
215
233
|
# Retire a specific resource.
|
|
216
234
|
def retire(resource)
|
|
217
|
-
Console.debug(self)
|
|
235
|
+
Console.debug(self){"Retire #{resource}"}
|
|
218
236
|
|
|
219
237
|
@resources.delete(resource)
|
|
220
238
|
|
|
221
239
|
resource.close
|
|
222
240
|
|
|
223
|
-
@
|
|
241
|
+
@mutex.synchronize{@condition.broadcast}
|
|
224
242
|
|
|
225
243
|
return true
|
|
226
244
|
end
|
|
@@ -236,12 +254,7 @@ module Async
|
|
|
236
254
|
@gardener = task
|
|
237
255
|
|
|
238
256
|
while true
|
|
239
|
-
|
|
240
|
-
@policy.call(self)
|
|
241
|
-
else
|
|
242
|
-
Task.yield
|
|
243
|
-
end
|
|
244
|
-
|
|
257
|
+
@policy&.call(self)
|
|
245
258
|
self.wait
|
|
246
259
|
end
|
|
247
260
|
ensure
|
|
@@ -269,7 +282,7 @@ module Async
|
|
|
269
282
|
# end
|
|
270
283
|
|
|
271
284
|
def reuse(resource)
|
|
272
|
-
Console.debug(self)
|
|
285
|
+
Console.debug(self){"Reuse #{resource}"}
|
|
273
286
|
|
|
274
287
|
usage = @resources[resource]
|
|
275
288
|
|
|
@@ -284,7 +297,7 @@ module Async
|
|
|
284
297
|
|
|
285
298
|
@resources[resource] = usage - 1
|
|
286
299
|
|
|
287
|
-
@
|
|
300
|
+
@mutex.synchronize{@condition.broadcast}
|
|
288
301
|
|
|
289
302
|
return true
|
|
290
303
|
end
|
|
@@ -292,11 +305,9 @@ module Async
|
|
|
292
305
|
def wait_for_resource
|
|
293
306
|
# If we fail to create a resource (below), we will end up waiting for one to become resources.
|
|
294
307
|
until resource = available_resource
|
|
295
|
-
@
|
|
308
|
+
@mutex.synchronize{@condition.wait(@mutex)}
|
|
296
309
|
end
|
|
297
|
-
|
|
298
310
|
# Be careful not to context switch or fail here.
|
|
299
|
-
|
|
300
311
|
return resource
|
|
301
312
|
end
|
|
302
313
|
|
|
@@ -328,7 +339,7 @@ module Async
|
|
|
328
339
|
end
|
|
329
340
|
|
|
330
341
|
return resource
|
|
331
|
-
rescue Exception
|
|
342
|
+
rescue Exception
|
|
332
343
|
reuse(resource) if resource
|
|
333
344
|
raise
|
|
334
345
|
end
|
|
@@ -344,10 +355,8 @@ module Async
|
|
|
344
355
|
return resource
|
|
345
356
|
end
|
|
346
357
|
end
|
|
347
|
-
|
|
348
|
-
@notification.wait
|
|
358
|
+
@mutex.synchronize{@condition.wait(@mutex)}
|
|
349
359
|
end
|
|
350
|
-
|
|
351
360
|
# Only when the pool has been completely drained, return nil:
|
|
352
361
|
return nil
|
|
353
362
|
end
|
|
@@ -375,7 +384,7 @@ module Async
|
|
|
375
384
|
end
|
|
376
385
|
|
|
377
386
|
if @limit.nil? or @resources.size < @limit
|
|
378
|
-
Console.debug(self)
|
|
387
|
+
Console.debug(self){"No available resources, allocating new one..."}
|
|
379
388
|
|
|
380
389
|
return create_resource
|
|
381
390
|
end
|
data/lib/async/pool/version.rb
CHANGED
|
@@ -13,7 +13,7 @@ Traces::Provider(Async::Pool::Controller) do
|
|
|
13
13
|
|
|
14
14
|
attributes.merge!(@tags) if @tags
|
|
15
15
|
|
|
16
|
-
Traces.trace("async.pool.create", attributes: attributes)
|
|
16
|
+
Traces.trace("async.pool.create", attributes: attributes){super}
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def drain(...)
|
|
@@ -23,7 +23,7 @@ Traces::Provider(Async::Pool::Controller) do
|
|
|
23
23
|
|
|
24
24
|
attributes.merge!(@tags) if @tags
|
|
25
25
|
|
|
26
|
-
Traces.trace("async.pool.drain", attributes: attributes)
|
|
26
|
+
Traces.trace("async.pool.drain", attributes: attributes){super}
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def acquire(...)
|
|
@@ -34,7 +34,7 @@ Traces::Provider(Async::Pool::Controller) do
|
|
|
34
34
|
|
|
35
35
|
attributes.merge!(@tags) if @tags
|
|
36
36
|
|
|
37
|
-
Traces.trace("async.pool.acquire", attributes: attributes)
|
|
37
|
+
Traces.trace("async.pool.acquire", attributes: attributes){super}
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def release(...)
|
|
@@ -44,7 +44,7 @@ Traces::Provider(Async::Pool::Controller) do
|
|
|
44
44
|
|
|
45
45
|
attributes.merge!(@tags) if @tags
|
|
46
46
|
|
|
47
|
-
Traces.trace("async.pool.release", attributes: attributes)
|
|
47
|
+
Traces.trace("async.pool.release", attributes: attributes){super}
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def retire(...)
|
|
@@ -54,6 +54,6 @@ Traces::Provider(Async::Pool::Controller) do
|
|
|
54
54
|
|
|
55
55
|
attributes.merge!(@tags) if @tags
|
|
56
56
|
|
|
57
|
-
Traces.trace("async.pool.retire", attributes: attributes)
|
|
57
|
+
Traces.trace("async.pool.retire", attributes: attributes){super}
|
|
58
58
|
end
|
|
59
59
|
end
|
data/license.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright, 2019-
|
|
3
|
+
Copyright, 2019-2025, by Samuel Williams.
|
|
4
4
|
Copyright, 2020, by Simon Perepelitsa.
|
|
5
5
|
Copyright, 2021, by Olle Jonsson.
|
|
6
6
|
Copyright, 2024, by Thomas Morgan.
|
|
7
|
+
Copyright, 2025, by Jean Boussier.
|
|
7
8
|
|
|
8
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
10
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
|
@@ -10,6 +10,12 @@ Please see the [project documentation](https://socketry.github.io/async-pool/) f
|
|
|
10
10
|
|
|
11
11
|
- [Getting Started](https://socketry.github.io/async-pool/guides/getting-started/index) - This guide explains how to use the `async-pool` gem to manage connection pooling.
|
|
12
12
|
|
|
13
|
+
## Releases
|
|
14
|
+
|
|
15
|
+
Please see the [project releases](https://socketry.github.io/async-pool/releases/index) for all releases.
|
|
16
|
+
|
|
17
|
+
### v0.11.0
|
|
18
|
+
|
|
13
19
|
## Contributing
|
|
14
20
|
|
|
15
21
|
We welcome contributions to this project.
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
%��HJ.�j��a��h^�%|���yt��sM�P\�V]�)?�i��
|
|
2
|
+
K<K4җzS�Vk����b5�ş�$�����&`V��:0���ao���o<��bB�!>�7mid��5�����2vٲ�V��$7�oi\�2蓬���=h�����m�@K\m+��c�p��x�M�x��*��j�}�%(+��ll�!&y/of9��Nۅ���HĬ�")
|
metadata
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async-pool
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
8
|
+
- Jean Boussier
|
|
8
9
|
- Olle Jonsson
|
|
9
10
|
- Simon Perepelitsa
|
|
10
11
|
- Thomas Morgan
|
|
@@ -39,7 +40,7 @@ cert_chain:
|
|
|
39
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
|
40
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
|
41
42
|
-----END CERTIFICATE-----
|
|
42
|
-
date:
|
|
43
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
43
44
|
dependencies:
|
|
44
45
|
- !ruby/object:Gem::Dependency
|
|
45
46
|
name: async
|
|
@@ -47,14 +48,14 @@ dependencies:
|
|
|
47
48
|
requirements:
|
|
48
49
|
- - ">="
|
|
49
50
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: '
|
|
51
|
+
version: '2.0'
|
|
51
52
|
type: :runtime
|
|
52
53
|
prerelease: false
|
|
53
54
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
55
|
requirements:
|
|
55
56
|
- - ">="
|
|
56
57
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: '
|
|
58
|
+
version: '2.0'
|
|
58
59
|
executables: []
|
|
59
60
|
extensions: []
|
|
60
61
|
extra_rdoc_files: []
|
|
@@ -66,6 +67,7 @@ files:
|
|
|
66
67
|
- lib/traces/provider/async/pool/controller.rb
|
|
67
68
|
- license.md
|
|
68
69
|
- readme.md
|
|
70
|
+
- releases.md
|
|
69
71
|
homepage: https://github.com/socketry/async-pool
|
|
70
72
|
licenses:
|
|
71
73
|
- MIT
|
|
@@ -80,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
80
82
|
requirements:
|
|
81
83
|
- - ">="
|
|
82
84
|
- !ruby/object:Gem::Version
|
|
83
|
-
version: '3.
|
|
85
|
+
version: '3.2'
|
|
84
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
87
|
requirements:
|
|
86
88
|
- - ">="
|
|
87
89
|
- !ruby/object:Gem::Version
|
|
88
90
|
version: '0'
|
|
89
91
|
requirements: []
|
|
90
|
-
rubygems_version: 3.6.
|
|
92
|
+
rubygems_version: 3.6.9
|
|
91
93
|
specification_version: 4
|
|
92
94
|
summary: A singleplex and multiplex resource pool for implementing robust clients.
|
|
93
95
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|