async-pool 0.3.11 → 0.3.12

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: 2b18ddc4cbc74698b642f3196160fe5a59b93ae0484d25a84da43cd1b2a9c90d
4
- data.tar.gz: 668b970b18cae244620c289909f72d9fcfe1bef70771ddaa9a9a251615fbfd08
3
+ metadata.gz: 0b1051396c5d474aee1dc09c05774e39d7f694220f39b70d13ba28296521fbfa
4
+ data.tar.gz: d217b6e200c52dba446af0c8677f6f5874ed5114607cccff941ac2c885fe7ad7
5
5
  SHA512:
6
- metadata.gz: cb6353d6ca63c11516d67183f722ff50e78428a86112d7e6fbb097f3706b02cbefa0768e0c38de64f662882ee70bdd8555f9c3d9654810a88fecf7284213495b
7
- data.tar.gz: 211e98500aa73c4a1fa6ca0bc944f39e859c3383e08b323a396b0fbd245239fe36804482f9d896aeb555097c8b79eecd4df393f643905964eb136a6a0a98c742
6
+ metadata.gz: 0c78ae68e5f37b5eef4e385db3b86d355143aa0fd1bd64aef84da4963b508ca621b4141aced44d4a649b20824203e0acda1474c05cadb456d2d277ed0ff3121e
7
+ data.tar.gz: 94b3019c786c2bac9d05ea1725651f35826f84050adb9813fcdfd12850619b349f1edfb229923fd5a9c4964c24b6c9e94d65fb0d6b970bc20559ce274c2928bf
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,22 +1,8 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
5
+ # Copyright, 2020, by Simon Perepelitsa.
20
6
 
21
7
  require 'console/logger'
22
8
 
@@ -119,8 +105,15 @@ module Async
119
105
  def close
120
106
  @available.clear
121
107
 
122
- @resources.each_key(&:close)
123
- @resources.clear
108
+ while pair = @resources.shift
109
+ resource, usage = pair
110
+
111
+ if usage > 0
112
+ Console.logger.warn(self, resource: resource, usage: usage) {"Closing resource while still in use!"}
113
+ end
114
+
115
+ resource.close
116
+ end
124
117
 
125
118
  @gardener&.stop
126
119
  end
@@ -139,12 +132,14 @@ module Async
139
132
  def prune(retain = 0)
140
133
  unused = []
141
134
 
135
+ # This code must not context switch:
142
136
  @resources.each do |resource, usage|
143
137
  if usage.zero?
144
138
  unused << resource
145
139
  end
146
140
  end
147
141
 
142
+ # It's okay for this to context switch:
148
143
  unused.each do |resource|
149
144
  if block_given?
150
145
  yield resource
@@ -1,22 +1,7 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
20
5
 
21
6
  require 'console/logger'
22
7
 
@@ -1,25 +1,10 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
20
5
 
21
6
  module Async
22
7
  module Pool
23
- VERSION = "0.3.11"
8
+ VERSION = "0.3.12"
24
9
  end
25
10
  end
data/lib/async/pool.rb CHANGED
@@ -1,23 +1,7 @@
1
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in
11
- # all copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- # THE SOFTWARE.
1
+ # frozen_string_literal: true
20
2
 
21
- require_relative 'pool/version'
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
6
+ require_relative 'pool/version'
23
7
  require_relative 'pool/controller'
data/license.md ADDED
@@ -0,0 +1,23 @@
1
+ # MIT License
2
+
3
+ Copyright, 2019-2022, by Samuel Williams.
4
+ Copyright, 2020, by Simon Perepelitsa.
5
+ Copyright, 2021, by Olle Jonsson.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,54 @@
1
+ # Async::Pool
2
+
3
+ Provides support for connection pooling both singleplex and multiplex resources.
4
+
5
+ [![Development Status](https://github.com/socketry/async-pool/workflows/Test/badge.svg)](https://github.com/socketry/async-pool/actions?workflow=Test)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ``` ruby
12
+ gem 'async-pool'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ``` bash
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ``` bash
24
+ $ gem install async-pool
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ `Async::Pool::Controller` provides support for both singleplex (one stream at a time) and multiplex resources (multiple streams at a time).
30
+
31
+ `Async::Pool::Resource` is provided as an interface and to document how to use the pools. However, you wouldn't need to use this in practice and just implement the appropriate interface on your own objects.
32
+
33
+ ``` ruby
34
+ pool = Async::Pool::Controller.new(Async::Pool::Resource)
35
+
36
+ pool.acquire do |resource|
37
+ # resource is implicitly released when exiting the block.
38
+ end
39
+
40
+ resource = pool.acquire
41
+
42
+ # Return the resource back to the pool:
43
+ pool.release(resource)
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ We welcome contributions to this project.
49
+
50
+ 1. Fork it.
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
53
+ 4. Push to the branch (`git push origin my-new-feature`).
54
+ 5. Create new Pull Request.
data.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- s��ʗ��G8���ED ʘ�V��l�#؟(����{ ���2:�������o�s3�{Xa��CrMmմ ����W9�> ,�?�� C
1
+ l�$��d�o� {lX��`�$�,� ������+�y��=A{��%�u�?ȵ\�?��e�ljl�k�jd�n�@
2
+ ���l|� 9+ၓ����Sa�Շ�`Ԋ ���7Y�)�H�ua�2f3�z4@�C"����z�̝0��� �w�����)��-�/j�K=�ʅ�`��q��H�df}�%{K�9o~(k��7�����4�!1mT�m��GR+ӻ��s�H��bs��~��$���]Om�i���[���t^1�A�E�ڑ� ��p6���7Ё���H=#�+_��;{t�LG$4�~��d�r:�UZ�y��n����vj5Ȉ�R�99D�.��xx� �~��Co%�4 01p�-<G�閿�]i�Ȏ�
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -39,7 +39,7 @@ cert_chain:
39
39
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
40
40
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
41
41
  -----END CERTIFICATE-----
42
- date: 2022-08-17 00:00:00.000000000 Z
42
+ date: 2022-08-28 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: async
@@ -56,19 +56,33 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: '1.25'
58
58
  - !ruby/object:Gem::Dependency
59
- name: async-rspec
59
+ name: bake-test
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - "~>"
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '1.1'
64
+ version: '0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: bake-test-external
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
70
84
  - !ruby/object:Gem::Version
71
- version: '1.1'
85
+ version: '0'
72
86
  - !ruby/object:Gem::Dependency
73
87
  name: bundler
74
88
  requirement: !ruby/object:Gem::Requirement
@@ -98,19 +112,33 @@ dependencies:
98
112
  - !ruby/object:Gem::Version
99
113
  version: '0'
100
114
  - !ruby/object:Gem::Dependency
101
- name: rspec
115
+ name: sus
102
116
  requirement: !ruby/object:Gem::Requirement
103
117
  requirements:
104
118
  - - "~>"
105
119
  - !ruby/object:Gem::Version
106
- version: '3.6'
120
+ version: '0.12'
107
121
  type: :development
108
122
  prerelease: false
109
123
  version_requirements: !ruby/object:Gem::Requirement
110
124
  requirements:
111
125
  - - "~>"
112
126
  - !ruby/object:Gem::Version
113
- version: '3.6'
127
+ version: '0.12'
128
+ - !ruby/object:Gem::Dependency
129
+ name: sus-fixtures-async
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
114
142
  description:
115
143
  email:
116
144
  executables: []
@@ -121,6 +149,8 @@ files:
121
149
  - lib/async/pool/controller.rb
122
150
  - lib/async/pool/resource.rb
123
151
  - lib/async/pool/version.rb
152
+ - license.md
153
+ - readme.md
124
154
  homepage: https://github.com/socketry/async-pool
125
155
  licenses:
126
156
  - MIT
metadata.gz.sig CHANGED
Binary file