async-pool 0.10.3 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56a5ccdbbda423ade08a5f3ecbd9078cb0593ff6c0747f0abc28ab7821a1f3b7
4
- data.tar.gz: 305a6dd845d03756c4b2a05d59fae42c1c847b693a8d8f6c1df3e146604ecc13
3
+ metadata.gz: fced21c28680f832d46cd11769b97d5a1dfd7a46761c58a144a1ff5ce178c7ff
4
+ data.tar.gz: e23c00cb8b7d48be97f5df59b6f05ea3728b40edbca97cda347740140d77621c
5
5
  SHA512:
6
- metadata.gz: 6647788461e0dda6cc136f9fde08bee8a3d81d66d3f1e56720e828d85cfaa90294c234892a45173c92571c706a790d0916e6238a1cc1cdf38b462032ae45d9ff
7
- data.tar.gz: b7496e871d2d380bf8e5f181b4c53a21cfe61995ab4626f381db354cb33fcca72410691ce9a4bf2a8ed1a267a30c94efa837c9be8a66bab6607f128847281c41
6
+ metadata.gz: a14bbfcb0c1dcd18f044de7caaf901c3ac17d80431342c0e584bd97d311d7d0acb12ec7004f5c0cf4942d406b90a2536ab9bb1297c393b03e3129572b082d342
7
+ data.tar.gz: b36b8d19bde4f2503781f828b2a8df3d871915dc852c942658c6779ffa51a0b7e4d29daab077e73a8967f9a2d3734df5437dd433d94aa8c7b9a9a38c4ef4d708
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-2024, by Samuel Williams.
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
- @notification = Async::Notification.new
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
- @notification.wait
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.
@@ -220,7 +238,7 @@ module Async
220
238
 
221
239
  resource.close
222
240
 
223
- @notification.signal
241
+ @mutex.synchronize {@condition.broadcast}
224
242
 
225
243
  return true
226
244
  end
@@ -284,7 +302,7 @@ module Async
284
302
 
285
303
  @resources[resource] = usage - 1
286
304
 
287
- @notification.signal
305
+ @mutex.synchronize {@condition.broadcast}
288
306
 
289
307
  return true
290
308
  end
@@ -292,11 +310,9 @@ module Async
292
310
  def wait_for_resource
293
311
  # If we fail to create a resource (below), we will end up waiting for one to become resources.
294
312
  until resource = available_resource
295
- @notification.wait
313
+ @mutex.synchronize {@condition.wait(@mutex)}
296
314
  end
297
-
298
315
  # Be careful not to context switch or fail here.
299
-
300
316
  return resource
301
317
  end
302
318
 
@@ -328,7 +344,7 @@ module Async
328
344
  end
329
345
 
330
346
  return resource
331
- rescue Exception => error
347
+ rescue Exception
332
348
  reuse(resource) if resource
333
349
  raise
334
350
  end
@@ -344,10 +360,8 @@ module Async
344
360
  return resource
345
361
  end
346
362
  end
347
-
348
- @notification.wait
363
+ @mutex.synchronize {@condition.wait(@mutex)}
349
364
  end
350
-
351
365
  # Only when the pool has been completely drained, return nil:
352
366
  return nil
353
367
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2024, by Samuel Williams.
4
+ # Copyright, 2019-2025, by Samuel Williams.
5
5
 
6
6
  module Async
7
7
  module Pool
8
- VERSION = "0.10.3"
8
+ VERSION = "0.11.0"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2024, by Samuel Williams.
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
@@ -0,0 +1,3 @@
1
+ # Releases
2
+
3
+ ## v0.11.0
data.tar.gz.sig CHANGED
Binary file
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.10.3
4
+ version: 0.11.0
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: 2025-02-01 00:00:00.000000000 Z
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: '1.25'
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: '1.25'
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.1'
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.2
92
+ rubygems_version: 3.6.7
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