async 2.0.2 → 2.0.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 +3 -0
- data/lib/async/queue.rb +20 -5
- data/lib/async/scheduler.rb +1 -5
- data/lib/async/task.rb +13 -16
- data/lib/async/version.rb +1 -1
- data/lib/async/wrapper.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +32 -4
- 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: 4e8368066a9018b0f3c21ee8c4387cebc233250a4d01697a06051aceee67924b
|
4
|
+
data.tar.gz: 80dbe862ee18e562c20acd59c428e2d9ef9b17097229621c3d22cdafb2705f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a0786f488161edbf99e3933f983938561d79f9d9f94902dcb4c79120ffe12c2743cc69aad1d258bbe1aae5bab10a90007ae0065e22576885377b11e423df1b
|
7
|
+
data.tar.gz: 224c584693a4a714d7cd9e10062c7975c7fbd8b785f84e46e44151acebb5bc74b136bb9eec5d1d828c5fbfc7cd853e29fb63cd5de3ae7afc8c232e2f9e0af722
|
checksums.yaml.gz.sig
ADDED
data/lib/async/queue.rb
CHANGED
@@ -43,14 +43,16 @@ module Async
|
|
43
43
|
@items.empty?
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
@items
|
46
|
+
def <<(item)
|
47
|
+
@items << item
|
48
48
|
|
49
49
|
self.signal unless self.empty?
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
|
52
|
+
def enqueue(*items)
|
53
|
+
@items.concat(items)
|
54
|
+
|
55
|
+
self.signal unless self.empty?
|
54
56
|
end
|
55
57
|
|
56
58
|
def dequeue
|
@@ -91,7 +93,7 @@ module Async
|
|
91
93
|
@items.size >= @limit
|
92
94
|
end
|
93
95
|
|
94
|
-
def
|
96
|
+
def <<(item)
|
95
97
|
while limited?
|
96
98
|
@full.wait
|
97
99
|
end
|
@@ -99,6 +101,19 @@ module Async
|
|
99
101
|
super
|
100
102
|
end
|
101
103
|
|
104
|
+
def enqueue *items
|
105
|
+
while !items.empty?
|
106
|
+
while limited?
|
107
|
+
@full.wait
|
108
|
+
end
|
109
|
+
|
110
|
+
available = @limit - @items.size
|
111
|
+
@items.concat(items.shift(available))
|
112
|
+
|
113
|
+
self.signal unless self.empty?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
102
117
|
def dequeue
|
103
118
|
item = super
|
104
119
|
|
data/lib/async/scheduler.rb
CHANGED
@@ -102,11 +102,7 @@ module Async
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def resume(fiber, *arguments)
|
105
|
-
|
106
|
-
@selector.resume(fiber, *arguments)
|
107
|
-
else
|
108
|
-
@selector.push(fiber)
|
109
|
-
end
|
105
|
+
@selector.resume(fiber, *arguments)
|
110
106
|
end
|
111
107
|
|
112
108
|
# Invoked when a fiber tries to perform a blocking operation which cannot continue. A corresponding call {unblock} must be performed to allow this fiber to continue.
|
data/lib/async/task.rb
CHANGED
@@ -163,7 +163,7 @@ module Async
|
|
163
163
|
if self.running?
|
164
164
|
if self.current?
|
165
165
|
if later
|
166
|
-
Fiber.scheduler.push
|
166
|
+
Fiber.scheduler.push(Stop::Later.new(self))
|
167
167
|
else
|
168
168
|
raise Stop, "Stopping current task!"
|
169
169
|
end
|
@@ -171,7 +171,7 @@ module Async
|
|
171
171
|
begin
|
172
172
|
Fiber.scheduler.raise(@fiber, Stop)
|
173
173
|
rescue FiberError
|
174
|
-
Fiber.scheduler.push
|
174
|
+
Fiber.scheduler.push(Stop::Later.new(self))
|
175
175
|
end
|
176
176
|
end
|
177
177
|
else
|
@@ -206,17 +206,13 @@ module Async
|
|
206
206
|
# Whether we can remove this node from the reactor graph.
|
207
207
|
# @returns [Boolean]
|
208
208
|
def finished?
|
209
|
-
super && @
|
209
|
+
super && @fiber.nil?
|
210
210
|
end
|
211
211
|
|
212
212
|
def failed?
|
213
213
|
@status == :failed
|
214
214
|
end
|
215
215
|
|
216
|
-
def stopping?
|
217
|
-
@status == :stopping
|
218
|
-
end
|
219
|
-
|
220
216
|
def stopped?
|
221
217
|
@status == :stopped
|
222
218
|
end
|
@@ -228,18 +224,19 @@ module Async
|
|
228
224
|
private
|
229
225
|
|
230
226
|
# This is a very tricky aspect of tasks to get right. I've modelled it after `Thread` but it's slightly different in that the exception can propagate back up through the reactor. If the user writes code which raises an exception, that exception should always be visible, i.e. cause a failure. If it's not visible, such code fails silently and can be very difficult to debug.
|
231
|
-
|
232
|
-
def fail!(exception = nil, propagate = true)
|
227
|
+
def fail!(exception = false, propagate = true)
|
233
228
|
@status = :failed
|
234
229
|
@result = exception
|
235
230
|
|
236
|
-
if
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
231
|
+
if exception
|
232
|
+
if propagate
|
233
|
+
raise exception
|
234
|
+
elsif @finished.nil?
|
235
|
+
# If no one has called wait, we log this as a warning:
|
236
|
+
Console.logger.warn(self, "Task may have ended with unhandled exception.", exception)
|
237
|
+
else
|
238
|
+
Console.logger.debug(self, exception)
|
239
|
+
end
|
243
240
|
end
|
244
241
|
end
|
245
242
|
|
data/lib/async/version.rb
CHANGED
data/lib/async/wrapper.rb
CHANGED
@@ -64,7 +64,7 @@ module Async
|
|
64
64
|
# Wait fo the io to become either readable or writable.
|
65
65
|
# @parameter duration [Float] timeout after the given duration if not `nil`.
|
66
66
|
def wait_any(timeout = @timeout)
|
67
|
-
@io.
|
67
|
+
@io.to_io.wait(::IO::READABLE|::IO::WRITABLE|::IO::PRIORITY, timeout) or raise TimeoutError
|
68
68
|
end
|
69
69
|
|
70
70
|
# Close the io and monitor.
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
- Devin Christensen
|
9
8
|
- Bruno Sutic
|
9
|
+
- Devin Christensen
|
10
10
|
- Jeremy Jung
|
11
11
|
- Kent Gruber
|
12
12
|
- jeremyjung
|
@@ -24,8 +24,36 @@ authors:
|
|
24
24
|
- muryoimpl
|
25
25
|
autorequire:
|
26
26
|
bindir: bin
|
27
|
-
cert_chain:
|
28
|
-
|
27
|
+
cert_chain:
|
28
|
+
- |
|
29
|
+
-----BEGIN CERTIFICATE-----
|
30
|
+
MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
|
31
|
+
ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
|
32
|
+
MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
|
33
|
+
aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
|
34
|
+
AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
|
35
|
+
xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
|
36
|
+
eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
|
37
|
+
L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
|
38
|
+
9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
|
39
|
+
E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0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6w=
|
55
|
+
-----END CERTIFICATE-----
|
56
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
29
57
|
dependencies:
|
30
58
|
- !ruby/object:Gem::Dependency
|
31
59
|
name: console
|
metadata.gz.sig
ADDED
Binary file
|