async-await 0.6.0 → 0.8.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/await/enumerable.rb +35 -36
- data/lib/async/await/version.rb +5 -20
- data/lib/async/await.rb +15 -25
- data/license.md +23 -0
- data/readme.md +29 -0
- data.tar.gz.sig +0 -0
- metadata +41 -68
- metadata.gz.sig +0 -0
- data/lib/async/await/methods.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27b16c1a38a595f31ccfbe742c2d29712ac97b4b9c56ab64e6a793b0b52291f
|
4
|
+
data.tar.gz: fd996d7db069e959fc9572ac4ec58a931e99fdc41e5c543eb5caf1e94d16051d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b7a82fe11c667443425e3da84cf349a010a9bf598fffe85e00e72cfb4598e92f30cc0bebbb8ca76af7c441e64b2709ba2648aa16254c1de7d2cba4bd7c97f38
|
7
|
+
data.tar.gz: 699dccb7567f8b139d06661e117500989c55071c99c50724243d9e6a8e43e6c2eb70d6cbebd5c81428adfc51227c3d128a0888a1226ee04be166754fbc458a70
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -1,38 +1,43 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
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, 2020-2025, by Samuel Williams.
|
5
|
+
|
6
|
+
require "async"
|
20
7
|
|
21
8
|
module Async
|
22
9
|
module Await
|
10
|
+
# Provide asynchronous methods for enumerables.
|
23
11
|
module Enumerable
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
# This method is used to map the elements of an enumerable collection asynchronously.
|
13
|
+
#
|
14
|
+
# @parameter parent [Interface(:async)] The parent to use for creating new tasks.
|
15
|
+
# @yields {|item| ...} The block to execute for each element in the collection.
|
16
|
+
def async_map(parent: nil, &block)
|
17
|
+
Sync do |task|
|
18
|
+
parent ||= task
|
19
|
+
|
20
|
+
self.map do |*arguments|
|
21
|
+
parent.async(finished: false) do
|
22
|
+
yield(*arguments)
|
23
|
+
end
|
24
|
+
end.map(&:wait)
|
25
|
+
end
|
30
26
|
end
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
# This method is used to iterate over the elements of an enumerable collection asynchronously.
|
29
|
+
#
|
30
|
+
# @parameter parent [Interface(:async)] The parent to use for creating new tasks.
|
31
|
+
# @yields {|item| ...} The block to execute for each element in the collection.
|
32
|
+
# @return [self] The original enumerable collection.
|
33
|
+
def async_each(parent: nil, &block)
|
34
|
+
Sync do |task|
|
35
|
+
parent ||= task
|
36
|
+
|
37
|
+
self.each do |*arguments|
|
38
|
+
parent.async do
|
39
|
+
yield(*arguments)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
@@ -42,10 +47,4 @@ module Async
|
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
45
|
-
|
46
|
-
# https://bugs.ruby-lang.org/issues/9573
|
47
|
-
module Enumerable
|
48
|
-
Async::Await::Enumerable.instance_methods.each do |name|
|
49
|
-
self.define_method(name, Async::Await::Enumerable.instance_method(name))
|
50
|
-
end
|
51
|
-
end
|
50
|
+
::Enumerable.include(Async::Await::Enumerable)
|
data/lib/async/await/version.rb
CHANGED
@@ -1,25 +1,10 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
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, 2017-2024, by Samuel Williams.
|
20
5
|
|
21
6
|
module Async
|
22
7
|
module Await
|
23
|
-
VERSION = "0.
|
8
|
+
VERSION = "0.8.0"
|
24
9
|
end
|
25
10
|
end
|
data/lib/async/await.rb
CHANGED
@@ -1,35 +1,22 @@
|
|
1
|
-
#
|
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
|
-
|
22
|
-
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2017-2025, by Samuel Williams.
|
23
5
|
|
24
|
-
|
6
|
+
require_relative "await/version"
|
25
7
|
|
8
|
+
# @namespace
|
26
9
|
module Async
|
10
|
+
# Provide a way to wrap methods so that they can be run synchronously or asynchronously in an event loop.
|
27
11
|
module Await
|
12
|
+
# A hook that is called when the module is included in a class in order to provide the class with the methods defined in this module.
|
28
13
|
def self.included(klass)
|
29
|
-
klass.include(Methods)
|
30
14
|
klass.extend(self)
|
31
15
|
end
|
32
16
|
|
17
|
+
# Wrap the method with the given name in a block that will run the method synchronously in an event loop.
|
18
|
+
#
|
19
|
+
# @parameter name [Symbol] The name of the method to wrap.
|
33
20
|
def sync(name)
|
34
21
|
original_method = instance_method(name)
|
35
22
|
|
@@ -45,9 +32,12 @@ module Async
|
|
45
32
|
end
|
46
33
|
end
|
47
34
|
|
48
|
-
|
35
|
+
return name
|
49
36
|
end
|
50
37
|
|
38
|
+
# Wrap the method with the given name in a block that will run the method asynchronously in an event loop.
|
39
|
+
#
|
40
|
+
# @parameter name [Symbol] The name of the method to wrap.
|
51
41
|
def async(name)
|
52
42
|
original_method = instance_method(name)
|
53
43
|
|
@@ -59,7 +49,7 @@ module Async
|
|
59
49
|
end
|
60
50
|
end
|
61
51
|
|
62
|
-
|
52
|
+
return name
|
63
53
|
end
|
64
54
|
end
|
65
55
|
end
|
data/license.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright, 2017-2025, by Samuel Williams.
|
4
|
+
Copyright, 2018, by Kent 'picat' Gruber.
|
5
|
+
Copyright, 2020, 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,29 @@
|
|
1
|
+
# Async::Await
|
2
|
+
|
3
|
+
Implements the async/await pattern for Ruby using [async](https://github.com/socketry/async).
|
4
|
+
|
5
|
+
[](https://github.com/socketry/async-await/actions?workflow=Test)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Please see the [project documentation](https://socketry.github.io/async-await/) for more details.
|
10
|
+
|
11
|
+
- [Getting Started](https://socketry.github.io/async-await/guides/getting-started/index) - This guide explains how to use `async-await` for implementing some common concurrency patterns.
|
12
|
+
|
13
|
+
## Contributing
|
14
|
+
|
15
|
+
We welcome contributions to this project.
|
16
|
+
|
17
|
+
1. Fork it.
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`).
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
21
|
+
5. Create new Pull Request.
|
22
|
+
|
23
|
+
### Developer Certificate of Origin
|
24
|
+
|
25
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
26
|
+
|
27
|
+
### Community Guidelines
|
28
|
+
|
29
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-await
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
|
8
|
+
- Kent 'picat' Gruber
|
9
|
+
- Olle Jonsson
|
9
10
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
15
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
16
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
17
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
18
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
19
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
20
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
21
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
22
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
23
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
24
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
25
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
26
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
27
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
28
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
29
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
30
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
31
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
32
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
33
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
34
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
35
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
36
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
37
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
38
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
|
+
-----END CERTIFICATE-----
|
41
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
12
42
|
dependencies:
|
13
43
|
- !ruby/object:Gem::Dependency
|
14
44
|
name: async
|
@@ -24,77 +54,21 @@ dependencies:
|
|
24
54
|
- - ">="
|
25
55
|
- !ruby/object:Gem::Version
|
26
56
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: ruby2_keywords
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: async-rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.1'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: covered
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.0'
|
83
|
-
description:
|
84
|
-
email:
|
85
57
|
executables: []
|
86
58
|
extensions: []
|
87
59
|
extra_rdoc_files: []
|
88
60
|
files:
|
89
61
|
- lib/async/await.rb
|
90
62
|
- lib/async/await/enumerable.rb
|
91
|
-
- lib/async/await/methods.rb
|
92
63
|
- lib/async/await/version.rb
|
64
|
+
- license.md
|
65
|
+
- readme.md
|
93
66
|
homepage: https://github.com/socketry/async-await
|
94
67
|
licenses:
|
95
68
|
- MIT
|
96
|
-
metadata:
|
97
|
-
|
69
|
+
metadata:
|
70
|
+
documentation_uri: https://socketry.github.io/async-await/
|
71
|
+
source_code_uri: https://github.com/socketry/async-await.git
|
98
72
|
rdoc_options: []
|
99
73
|
require_paths:
|
100
74
|
- lib
|
@@ -102,15 +76,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
76
|
requirements:
|
103
77
|
- - ">="
|
104
78
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
79
|
+
version: '3.1'
|
106
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
81
|
requirements:
|
108
82
|
- - ">="
|
109
83
|
- !ruby/object:Gem::Version
|
110
84
|
version: '0'
|
111
85
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
-
signing_key:
|
86
|
+
rubygems_version: 3.6.2
|
114
87
|
specification_version: 4
|
115
88
|
summary: Implements the async/await pattern on top of async :)
|
116
89
|
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/async/await/methods.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# Copyright, 2018, 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.
|
20
|
-
|
21
|
-
require 'async/reactor'
|
22
|
-
|
23
|
-
module Async
|
24
|
-
module Await
|
25
|
-
module Methods
|
26
|
-
extend Forwardable
|
27
|
-
|
28
|
-
def task
|
29
|
-
Async::Task.current
|
30
|
-
end
|
31
|
-
|
32
|
-
def_delegators :task, :with_timeout, :sleep, :async
|
33
|
-
|
34
|
-
def await(&block)
|
35
|
-
block.call.wait
|
36
|
-
end
|
37
|
-
|
38
|
-
def barrier!
|
39
|
-
task.children.each(&:wait)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|