async 2.6.2 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/conduct.md +133 -0
- data/lib/async/barrier.md +5 -1
- data/lib/async/node.rb +1 -1
- data/lib/async/scheduler.rb +27 -8
- data/lib/async/task.md +30 -0
- data/lib/async/task.rb +1 -21
- data/lib/async/version.rb +2 -2
- data/license.md +2 -0
- data/readme.md +23 -4
- data.tar.gz.sig +0 -0
- metadata +21 -16
- 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: 85ce7982fbc951dc88c43f5c19fe6d8bbbdd9bfe4dac1d624dbbea07a5d7a6a5
|
4
|
+
data.tar.gz: 30efe433816cc976e2380332fe86baaa6b7175624d2d3cd9ee46c7c23781007b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 612c391a6aaed9f793383023f1f29b304d72f1fbb391bc4c320e37ec651708c219026f2488466fcb3731d732d32a47822cd219fa754353f915e3263e7e5c66ce
|
7
|
+
data.tar.gz: 817645de248bf18e360a7b9d799e900ec3165a1fb16a42efcfa198379c1fb347285f1839fd92d835f0c1dafe08f2a26420b3326e68d6bb023ab2fedce1070f50
|
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
data/lib/async/scheduler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
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
|
-
|
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
|
@@ -205,6 +208,7 @@ module Async
|
|
205
208
|
end
|
206
209
|
|
207
210
|
# Run one iteration of the event loop.
|
211
|
+
# Does not handle interrupts.
|
208
212
|
# @parameter timeout [Float | Nil] The maximum timeout, or if nil, indefinite.
|
209
213
|
# @returns [Boolean] Whether there is more work to do.
|
210
214
|
def run_once(timeout = nil)
|
@@ -250,20 +254,35 @@ module Async
|
|
250
254
|
return true
|
251
255
|
end
|
252
256
|
|
257
|
+
# Checks and clears the interrupted state of the scheduler.
|
258
|
+
# @returns [Boolean] Whether the reactor has been interrupted.
|
259
|
+
private def interrupted?
|
260
|
+
if @interrupted
|
261
|
+
@interrupted = false
|
262
|
+
return true
|
263
|
+
end
|
264
|
+
|
265
|
+
if Thread.pending_interrupt?
|
266
|
+
return true
|
267
|
+
end
|
268
|
+
|
269
|
+
return false
|
270
|
+
end
|
271
|
+
|
253
272
|
# Run the reactor until all tasks are finished. Proxies arguments to {#async} immediately before entering the loop, if a block is provided.
|
254
273
|
def run(...)
|
255
274
|
Kernel::raise ClosedError if @selector.nil?
|
256
275
|
|
257
276
|
initial_task = self.async(...) if block_given?
|
258
277
|
|
259
|
-
@interrupted = false
|
260
|
-
|
261
278
|
# 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
279
|
Thread.handle_interrupt(SignalException => :never) do
|
263
|
-
while
|
264
|
-
|
265
|
-
|
266
|
-
|
280
|
+
while true
|
281
|
+
# If we are interrupted, we need to exit:
|
282
|
+
break if self.interrupted?
|
283
|
+
|
284
|
+
# If we are finished, we need to exit:
|
285
|
+
break unless self.run_once
|
267
286
|
end
|
268
287
|
end
|
269
288
|
|
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-
|
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
|
data/lib/async/version.rb
CHANGED
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
|
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 –
|
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
|
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.
|
4
|
+
version: 2.6.3
|
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-
|
61
|
+
date: 2023-07-28 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:
|
78
|
+
name: fiber-annotation
|
77
79
|
requirement: !ruby/object:Gem::Requirement
|
78
80
|
requirements:
|
79
|
-
- - "
|
81
|
+
- - ">="
|
80
82
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
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: '
|
90
|
+
version: '0'
|
89
91
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
92
|
+
name: io-event
|
91
93
|
requirement: !ruby/object:Gem::Requirement
|
92
94
|
requirements:
|
93
95
|
- - "~>"
|
94
96
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
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: '
|
104
|
+
version: '1.1'
|
103
105
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
106
|
+
name: timers
|
105
107
|
requirement: !ruby/object:Gem::Requirement
|
106
108
|
requirements:
|
107
|
-
- - "
|
109
|
+
- - "~>"
|
108
110
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
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: '
|
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:
|
metadata.gz.sig
CHANGED
Binary file
|