async 2.6.2 → 2.6.4

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: 7ca106126076f17e48b0374812121cb9d30bc9e5eac981b52407db946ce41e00
4
- data.tar.gz: '0302068031a9aee009ec0fbf1a5045fdae48031f4c2f2ff1914f45c292dd6915'
3
+ metadata.gz: d54225f46397da0fca5df7594cce6d324448f5232437bd280427bac01cdfc611
4
+ data.tar.gz: d83c10b361eb4b86891e5779dfd2b434d2235a9f381384faf10399da40ef1120
5
5
  SHA512:
6
- metadata.gz: 865d56ad3386151e7f417fe00343946be99ae60d620948718e28856aa59fc7f82e8ba28debebb3d025c3a852878456b940dc7e99a1f3a7591873ac7d3a139b2b
7
- data.tar.gz: 90d108eb53e337ad33b8655c70aaeb22acc64eba534a7096cd9053938ab3654858e4a72a7d2872ffaaa7c708ba2049c629c30a7a00ace4b370f799e99da85525
6
+ metadata.gz: 8dc3b8d9c4e84139b0a0b3e4293c7a9057fea467374a30a8ed3290b48ac7d623f04c9c00013ffe8f2b8cedcd48b277da173c59985f78a09c62cd845168a1152e
7
+ data.tar.gz: 5cc169eb3b18e594474c3bccf957fdaa661322fa4715b2b0a9d025162d3c54a44e6a464b98f9dc157ad2cdf75a3c2a2369ce959066827b46f6ada37572d8e455
checksums.yaml.gz.sig CHANGED
Binary file
data/conduct.md ADDED
@@ -0,0 +1,133 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, caste, color, religion, or sexual
11
+ identity and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the overall
27
+ community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or advances of
32
+ any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email address,
36
+ without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ [INSERT CONTACT METHOD].
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series of
87
+ actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or permanent
94
+ ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within the
114
+ community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.1, available at
120
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127
+ [https://www.contributor-covenant.org/translations][translations].
128
+
129
+ [homepage]: https://www.contributor-covenant.org
130
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131
+ [Mozilla CoC]: https://github.com/mozilla/diversity
132
+ [FAQ]: https://www.contributor-covenant.org/faq
133
+ [translations]: https://www.contributor-covenant.org/translations
data/lib/async/barrier.md CHANGED
@@ -1,14 +1,15 @@
1
1
  A synchronization primitive, which allows one task to wait for a number of other tasks to complete. It can be used in conjunction with {Semaphore}.
2
2
 
3
+
3
4
  ## Example
4
5
 
5
6
  ~~~ ruby
6
7
  require 'async'
7
8
  require 'async/barrier'
8
9
 
10
+ barrier = Async::Barrier.new
9
11
  Sync do
10
12
  Console.logger.info("Barrier Example: sleep sort.")
11
- barrier = Async::Barrier.new
12
13
 
13
14
  # Generate an array of 10 numbers:
14
15
  numbers = 10.times.map{rand(10)}
@@ -26,6 +27,9 @@ Sync do
26
27
  barrier.wait
27
28
 
28
29
  Console.logger.info("Sorted", sorted)
30
+ ensure
31
+ # Ensure all the tasks are stopped when we exit:
32
+ barrier.stop
29
33
  end
30
34
  ~~~
31
35
 
data/lib/async/node.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2023, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2022, by Shannon Skipper.
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2022, by Samuel Williams.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
5
  # Copyright, 2020, by Jun Jiang.
6
6
  # Copyright, 2021, by Julien Portalier.
7
7
 
@@ -41,7 +41,10 @@ module Async
41
41
  end
42
42
 
43
43
  def scheduler_close
44
- self.run
44
+ # If the execution context (thread) was handling an exception, we want to exit as quickly as possible:
45
+ unless $!
46
+ self.run
47
+ end
45
48
  ensure
46
49
  self.close
47
50
  end
@@ -168,17 +171,11 @@ module Async
168
171
 
169
172
  if timeout
170
173
  timer = @timers.after(timeout) do
171
- fiber.raise(TimeoutError)
174
+ fiber.transfer
172
175
  end
173
176
  end
174
177
 
175
- # Console.logger.info(self, "-> io_wait", fiber, io, events)
176
- events = @selector.io_wait(fiber, io, events)
177
- # Console.logger.info(self, "<- io_wait", fiber, io, events)
178
-
179
- return events
180
- rescue TimeoutError
181
- return false
178
+ return @selector.io_wait(fiber, io, events)
182
179
  ensure
183
180
  timer&.cancel
184
181
  end
@@ -205,6 +202,7 @@ module Async
205
202
  end
206
203
 
207
204
  # Run one iteration of the event loop.
205
+ # Does not handle interrupts.
208
206
  # @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
209
207
  # @returns [Boolean] Whether there is more work to do.
210
208
  def run_once(timeout = nil)
@@ -250,20 +248,35 @@ module Async
250
248
  return true
251
249
  end
252
250
 
251
+ # Checks and clears the interrupted state of the scheduler.
252
+ # @returns [Boolean] Whether the reactor has been interrupted.
253
+ private def interrupted?
254
+ if @interrupted
255
+ @interrupted = false
256
+ return true
257
+ end
258
+
259
+ if Thread.pending_interrupt?
260
+ return true
261
+ end
262
+
263
+ return false
264
+ end
265
+
253
266
  # Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
254
267
  def run(...)
255
268
  Kernel::raise ClosedError if @selector.nil?
256
269
 
257
270
  initial_task = self.async(...) if block_given?
258
271
 
259
- @interrupted = false
260
-
261
272
  # In theory, we could use Exception here to be a little bit safer, but we've only shown the case for SignalException to be a problem, so let's not over-engineer this.
262
273
  Thread.handle_interrupt(SignalException => :never) do
263
- while self.run_once
264
- if @interrupted || Thread.pending_interrupt?
265
- break
266
- end
274
+ while true
275
+ # If we are interrupted, we need to exit:
276
+ break if self.interrupted?
277
+
278
+ # If we are finished, we need to exit:
279
+ break unless self.run_once
267
280
  end
268
281
  end
269
282
 
data/lib/async/task.md ADDED
@@ -0,0 +1,30 @@
1
+ A sequence of instructions, defined by a block, which is executed sequentially and managed by the scheduler. A task can be in one of the following states: `initialized`, `running`, `completed`, `failed`, `cancelled` or `stopped`.
2
+
3
+ ```mermaid
4
+ stateDiagram-v2
5
+ [*] --> Initialized
6
+ Initialized --> Running : Run
7
+
8
+ Running --> Completed : Return Value
9
+ Running --> Failed : Exception
10
+
11
+ Completed --> [*]
12
+ Failed --> [*]
13
+
14
+ Running --> Stopped : Stop
15
+ Stopped --> [*]
16
+ Completed --> Stopped : Stop
17
+ Failed --> Stopped : Stop
18
+ Initialized --> Stopped : Stop
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```ruby
24
+ require 'async'
25
+
26
+ # Create an asynchronous task that sleeps for 1 second:
27
+ Async do |task|
28
+ sleep(1)
29
+ end
30
+ ```
data/lib/async/task.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2023, by Samuel Williams.
5
5
  # Copyright, 2017, by Kent Gruber.
6
6
  # Copyright, 2017, by Devin Christensen.
7
7
  # Copyright, 2020, by Patrik Wenger.
@@ -37,26 +37,6 @@ module Async
37
37
  end
38
38
  end
39
39
 
40
- # Encapsulates the state of a running task and it's result.
41
- #
42
- # ```mermaid
43
- # stateDiagram-v2
44
- # [*] --> Initialized
45
- # Initialized --> Running : Run
46
- #
47
- # Running --> Completed : Return Value
48
- # Running --> Failed : Exception
49
- #
50
- # Completed --> [*]
51
- # Failed --> [*]
52
- #
53
- # Running --> Stopped : Stop
54
- # Stopped --> [*]
55
- # Completed --> Stopped : Stop
56
- # Failed --> Stopped : Stop
57
- # Initialized --> Stopped : Stop
58
- # ```
59
- #
60
40
  # @public Since `stable-v1`.
61
41
  class Task < Node
62
42
  class FinishedError < RuntimeError
@@ -210,7 +190,7 @@ module Async
210
190
  @finished.wait
211
191
  end
212
192
 
213
- if @result.is_a?(Exception)
193
+ if @status == :failed
214
194
  raise @result
215
195
  else
216
196
  return @result
data/lib/async/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2017-2022, by Samuel Williams.
4
+ # Copyright, 2017-2023, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.6.2"
7
+ VERSION = "2.6.4"
8
8
  end
data/license.md CHANGED
@@ -20,6 +20,8 @@ Copyright, 2022, by Shannon Skipper.
20
20
  Copyright, 2022, by Masafumi Okura.
21
21
  Copyright, 2022, by Trevor Turk.
22
22
  Copyright, 2022, by Masayuki Yamamoto.
23
+ Copyright, 2023, by Leon Löchner.
24
+ Copyright, 2023, by Colin Kelley.
23
25
 
24
26
  Permission is hereby granted, free of charge, to any person obtaining a copy
25
27
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # ![Async](logo.svg)
2
2
 
3
- Async is a composable asynchronous I/O framework for Ruby based on [io-event](https://github.com/socketry/io-event) and [timers](https://github.com/socketry/timers).
3
+ Async is a composable asynchronous I/O framework for Ruby based on [io-event](https://github.com/socketry/io-event) and
4
+ [timers](https://github.com/socketry/timers).
4
5
 
5
- > "Lately I've been looking into `async`, as one of my projects – [tus-ruby-server](https://github.com/janko/tus-ruby-server) – would really benefit from non-blocking I/O. It's really beautifully designed." *– [janko](https://github.com/janko)*
6
+ > "Lately I've been looking into `async`, as one of my projects –
7
+ > [tus-ruby-server](https://github.com/janko/tus-ruby-server) – would really benefit from non-blocking I/O. It's really
8
+ > beautifully designed." *– [janko](https://github.com/janko)*
6
9
 
7
- [![Development Status](https://github.com/socketry/async/workflows/Test/badge.svg)](https://github.com/socketry/async/actions?workflow=Test)
10
+ [![Development
11
+ Status](https://github.com/socketry/async/workflows/Test/badge.svg)](https://github.com/socketry/async/actions?workflow=Test)
8
12
 
9
13
  ## Features
10
14
 
@@ -15,7 +19,22 @@ Async is a composable asynchronous I/O framework for Ruby based on [io-event](ht
15
19
 
16
20
  ## Usage
17
21
 
18
- Please see the [project documentation](https://socketry.github.io/async).
22
+ Please see the [project documentation](https://socketry.github.io/async/) for more details.
23
+
24
+ - [Getting Started](https://socketry.github.io/async/guides/getting-started/index) - This guide gives shows how to add
25
+ async to your project and run code asynchronously.
26
+
27
+ - [Asynchronous Tasks](https://socketry.github.io/async/guides/asynchronous-tasks/index) - This guide explains how
28
+ asynchronous tasks work and how to use them.
29
+
30
+ - [Event Loop](https://socketry.github.io/async/guides/event-loop/index) - This guide gives an overview of how the
31
+ event loop is implemented.
32
+
33
+ - [Compatibility](https://socketry.github.io/async/guides/compatibility/index) - This guide gives an overview of the
34
+ compatibility of Async with Ruby and other frameworks.
35
+
36
+ - [Best Practices](https://socketry.github.io/async/guides/best-practices/index) - This guide gives an overview of
37
+ best practices for using Async.
19
38
 
20
39
  ## Contributing
21
40
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -10,10 +10,12 @@ authors:
10
10
  - Devin Christensen
11
11
  - Kent Gruber
12
12
  - Brian Morearty
13
+ - Colin Kelley
13
14
  - Jiang Jinyang
14
15
  - Julien Portalier
15
16
  - Jun Jiang
16
17
  - Ken Muryoi
18
+ - Leon Löchner
17
19
  - Masafumi Okura
18
20
  - Masayuki Yamamoto
19
21
  - Olle Jonsson
@@ -56,7 +58,7 @@ cert_chain:
56
58
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
57
59
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
58
60
  -----END CERTIFICATE-----
59
- date: 2023-06-13 00:00:00.000000000 Z
61
+ date: 2023-08-25 00:00:00.000000000 Z
60
62
  dependencies:
61
63
  - !ruby/object:Gem::Dependency
62
64
  name: console
@@ -73,47 +75,47 @@ dependencies:
73
75
  - !ruby/object:Gem::Version
74
76
  version: '1.10'
75
77
  - !ruby/object:Gem::Dependency
76
- name: io-event
78
+ name: fiber-annotation
77
79
  requirement: !ruby/object:Gem::Requirement
78
80
  requirements:
79
- - - "~>"
81
+ - - ">="
80
82
  - !ruby/object:Gem::Version
81
- version: '1.1'
83
+ version: '0'
82
84
  type: :runtime
83
85
  prerelease: false
84
86
  version_requirements: !ruby/object:Gem::Requirement
85
87
  requirements:
86
- - - "~>"
88
+ - - ">="
87
89
  - !ruby/object:Gem::Version
88
- version: '1.1'
90
+ version: '0'
89
91
  - !ruby/object:Gem::Dependency
90
- name: timers
92
+ name: io-event
91
93
  requirement: !ruby/object:Gem::Requirement
92
94
  requirements:
93
95
  - - "~>"
94
96
  - !ruby/object:Gem::Version
95
- version: '4.1'
97
+ version: '1.1'
96
98
  type: :runtime
97
99
  prerelease: false
98
100
  version_requirements: !ruby/object:Gem::Requirement
99
101
  requirements:
100
102
  - - "~>"
101
103
  - !ruby/object:Gem::Version
102
- version: '4.1'
104
+ version: '1.1'
103
105
  - !ruby/object:Gem::Dependency
104
- name: fiber-annotation
106
+ name: timers
105
107
  requirement: !ruby/object:Gem::Requirement
106
108
  requirements:
107
- - - ">="
109
+ - - "~>"
108
110
  - !ruby/object:Gem::Version
109
- version: '0'
111
+ version: '4.1'
110
112
  type: :runtime
111
113
  prerelease: false
112
114
  version_requirements: !ruby/object:Gem::Requirement
113
115
  requirements:
114
- - - ">="
116
+ - - "~>"
115
117
  - !ruby/object:Gem::Version
116
- version: '0'
118
+ version: '4.1'
117
119
  - !ruby/object:Gem::Dependency
118
120
  name: bake-test
119
121
  requirement: !ruby/object:Gem::Requirement
@@ -218,6 +220,7 @@ executables: []
218
220
  extensions: []
219
221
  extra_rdoc_files: []
220
222
  files:
223
+ - conduct.md
221
224
  - lib/async.rb
222
225
  - lib/async/barrier.md
223
226
  - lib/async/barrier.rb
@@ -232,6 +235,7 @@ files:
232
235
  - lib/async/scheduler.rb
233
236
  - lib/async/semaphore.md
234
237
  - lib/async/semaphore.rb
238
+ - lib/async/task.md
235
239
  - lib/async/task.rb
236
240
  - lib/async/variable.rb
237
241
  - lib/async/version.rb
@@ -245,7 +249,8 @@ files:
245
249
  homepage: https://github.com/socketry/async
246
250
  licenses:
247
251
  - MIT
248
- metadata: {}
252
+ metadata:
253
+ documentation_uri: https://socketry.github.io/async/
249
254
  post_install_message:
250
255
  rdoc_options: []
251
256
  require_paths:
@@ -261,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
266
  - !ruby/object:Gem::Version
262
267
  version: '0'
263
268
  requirements: []
264
- rubygems_version: 3.4.7
269
+ rubygems_version: 3.5.0.dev
265
270
  signing_key:
266
271
  specification_version: 4
267
272
  summary: A concurrency framework for Ruby.
metadata.gz.sig CHANGED
Binary file