async 2.3.1 → 2.4.1

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: 042a45792628d56b89e02200e38d6d00fb16c5311b95c3dae7d52607aef8108a
4
- data.tar.gz: 6e7b3271d484ee3aabe395996ca987b1e0043d6d8710b3b706688993df43c916
3
+ metadata.gz: e0734cd025e0357960356ceac7c51d2a3c33efe60f62fcd0ab3d09a528866d7b
4
+ data.tar.gz: b9658e9b523e90a8d863c2f52cbf4fc8492fe42e6cc63422cb9af2af50582362
5
5
  SHA512:
6
- metadata.gz: 49ea21f4f81b9e566119265b834ecbfb4de8db83788370e18d3d27b14e7a2ec972960f67301139dd61111f13843325264412bf096b5b33cafff910630b1663cb
7
- data.tar.gz: 151eee11c70bf263c72cae52142168449ba38cd68a00ad302c2c9fcf53088de65784f35193971628e6c1ddb9d7efab9677359040ed19e13cde1f846670fd9b3e
6
+ metadata.gz: 0436e9692d113d2ee40e76e3c792f7ae81a7c563bc93cfe04470fcb84c610795d49a35dfaffa4f7c7f62d2b20efe316d796ca1a573bd997f654db5ba55f9f07a
7
+ data.tar.gz: 031eab57b8164cd1aa040a4e10d509d3c32db61331cda40c9a5689ef49b199f1d107e0edc154aa2bd5377ea848e0bdaf943b14ba3d3f5d30619c5dcef5ec496a
checksums.yaml.gz.sig CHANGED
Binary file
@@ -50,9 +50,12 @@ module Async
50
50
  # We depend on GVL for consistency:
51
51
  # @guard.synchronize do
52
52
 
53
- @selector&.close
53
+ # We want `@selector = nil` to be a visible side effect from this point forward, specifically in `#interrupt` and `#unblock`. If the selector is closed, then we don't want to push any fibers to it.
54
+ selector = @selector
54
55
  @selector = nil
55
56
 
57
+ selector&.close
58
+
56
59
  # end
57
60
 
58
61
  consume
@@ -69,9 +72,10 @@ module Async
69
72
  end
70
73
 
71
74
  # Interrupt the event loop and cause it to exit.
75
+ # @asynchronous May be called from any thread.
72
76
  def interrupt
73
77
  @interrupted = true
74
- @selector.wakeup
78
+ @selector&.wakeup
75
79
  end
76
80
 
77
81
  # Transfer from the calling fiber to the event loop.
@@ -127,8 +131,10 @@ module Async
127
131
  # $stderr.puts "unblock(#{blocker}, #{fiber})"
128
132
 
129
133
  # This operation is protected by the GVL:
130
- @selector.push(fiber)
131
- @selector.wakeup
134
+ if selector = @selector
135
+ selector.push(fiber)
136
+ selector.wakeup
137
+ end
132
138
  end
133
139
 
134
140
  # @asynchronous May be non-blocking..
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2022, by Samuel Williams.
4
+ # Copyright, 2018-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'list'
7
7
 
@@ -28,6 +28,25 @@ module Async
28
28
  # The tasks waiting on this semaphore.
29
29
  attr :waiting
30
30
 
31
+ # Allow setting the limit. This is useful for cases where the semaphore is used to limit the number of concurrent tasks, but the number of tasks is not known in advance or needs to be modified.
32
+ #
33
+ # On increasing the limit, some tasks may be immediately resumed. On decreasing the limit, some tasks may execute until the count is < than the limit.
34
+ #
35
+ # @parameter limit [Integer] The new limit.
36
+ def limit= limit
37
+ difference = limit - @limit
38
+ @limit = limit
39
+
40
+ # We can't suspend
41
+ if difference > 0
42
+ difference.times do
43
+ break unless node = @waiting.first
44
+
45
+ node.resume
46
+ end
47
+ end
48
+ end
49
+
31
50
  # Is the semaphore currently acquired?
32
51
  def empty?
33
52
  @count.zero?
data/lib/async/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2017-2022, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.3.1"
7
+ VERSION = "2.4.1"
8
8
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2017-2022, by Samuel Williams.
3
+ Copyright, 2017-2023, by Samuel Williams.
4
4
  Copyright, 2017, by Kent Gruber.
5
5
  Copyright, 2017, by Devin Christensen.
6
6
  Copyright, 2018, by Sokolov Yura.
@@ -17,6 +17,9 @@ Copyright, 2020, by Jun Jiang.
17
17
  Copyright, 2020-2022, by Bruno Sutic.
18
18
  Copyright, 2021, by Julien Portalier.
19
19
  Copyright, 2022, by Shannon Skipper.
20
+ Copyright, 2022, by Masafumi Okura.
21
+ Copyright, 2022, by Trevor Turk.
22
+ Copyright, 2022, by Masayuki Yamamoto.
20
23
 
21
24
  Permission is hereby granted, free of charge, to any person obtaining a copy
22
25
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -42,27 +42,3 @@ We welcome contributions to this project.
42
42
  - [falcon](https://github.com/socketry/falcon) — A rack compatible server built on top of `async-http`.
43
43
  - [rubydns](https://github.com/ioquatix/rubydns) — An easy to use Ruby DNS server.
44
44
  - [slack-ruby-bot](https://github.com/slack-ruby/slack-ruby-bot) — A client for making slack bots.
45
-
46
- ## License
47
-
48
- Released under the MIT license.
49
-
50
- Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com).
51
-
52
- Permission is hereby granted, free of charge, to any person obtaining a copy
53
- of this software and associated documentation files (the "Software"), to deal
54
- in the Software without restriction, including without limitation the rights
55
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
56
- copies of the Software, and to permit persons to whom the Software is
57
- furnished to do so, subject to the following conditions:
58
-
59
- The above copyright notice and this permission notice shall be included in
60
- all copies or substantial portions of the Software.
61
-
62
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
68
- THE SOFTWARE.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Bruno Sutic
9
- - Devin Christensen
10
9
  - Jeremy Jung
10
+ - Devin Christensen
11
11
  - Kent Gruber
12
- - jeremyjung
13
12
  - Brian Morearty
14
13
  - Jiang Jinyang
15
14
  - Julien Portalier
15
+ - Jun Jiang
16
+ - Ken Muryoi
17
+ - Masafumi Okura
18
+ - Masayuki Yamamoto
16
19
  - Olle Jonsson
17
20
  - Patrik Wenger
18
21
  - Ryan Musgrave
19
22
  - Salim Semaoune
20
23
  - Shannon Skipper
21
- - Sokolov Yura aka funny_falcon
24
+ - Sokolov Yura
22
25
  - Stefan Wrobel
23
- - jasl
24
- - muryoimpl
26
+ - Trevor Turk
25
27
  autorequire:
26
28
  bindir: bin
27
29
  cert_chain:
@@ -54,7 +56,7 @@ cert_chain:
54
56
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
55
57
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
56
58
  -----END CERTIFICATE-----
57
- date: 2022-12-28 00:00:00.000000000 Z
59
+ date: 2023-03-07 00:00:00.000000000 Z
58
60
  dependencies:
59
61
  - !ruby/object:Gem::Dependency
60
62
  name: console
@@ -259,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
261
  - !ruby/object:Gem::Version
260
262
  version: '0'
261
263
  requirements: []
262
- rubygems_version: 3.4.1
264
+ rubygems_version: 3.4.7
263
265
  signing_key:
264
266
  specification_version: 4
265
267
  summary: A concurrency framework for Ruby.
metadata.gz.sig CHANGED
Binary file