async 1.30.2 → 1.30.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/queue.rb +20 -5
- data/lib/async/task.rb +10 -9
- data/lib/async/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7bcca0b0eba6eebe85dd32baa0ffd67059bcdb0623416b818182bf779e38809
|
4
|
+
data.tar.gz: 061a086ae31c238f1d2c3d17598400f3efc01a500de746105255f7582b90251c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 455f569e561177f4f2e11e5f5713c6e04c5b30b54b01e860bca5e84770095b7f80c0d05d6afa7865773fbfb58c4170103a905ce9c3517c08fb9eec32f5a191a9
|
7
|
+
data.tar.gz: b142a77817fcf868fa68f117d68fe05cf3d0ce34329855a2ef19be198924604b366deaa0ac0ec7bcaa151eaf244bb1e521908515aca44b5be1d82f794288f313
|
data/lib/async/queue.rb
CHANGED
@@ -42,14 +42,16 @@ module Async
|
|
42
42
|
@items.empty?
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
@items
|
45
|
+
def <<(item)
|
46
|
+
@items << item
|
47
47
|
|
48
48
|
self.signal unless self.empty?
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
51
|
+
def enqueue(*items)
|
52
|
+
@items.concat(items)
|
53
|
+
|
54
|
+
self.signal unless self.empty?
|
53
55
|
end
|
54
56
|
|
55
57
|
def dequeue
|
@@ -89,7 +91,7 @@ module Async
|
|
89
91
|
@items.size >= @limit
|
90
92
|
end
|
91
93
|
|
92
|
-
def
|
94
|
+
def <<(item)
|
93
95
|
while limited?
|
94
96
|
@full.wait
|
95
97
|
end
|
@@ -97,6 +99,19 @@ module Async
|
|
97
99
|
super
|
98
100
|
end
|
99
101
|
|
102
|
+
def enqueue *items
|
103
|
+
while !items.empty?
|
104
|
+
while limited?
|
105
|
+
@full.wait
|
106
|
+
end
|
107
|
+
|
108
|
+
available = @limit - @items.size
|
109
|
+
@items.concat(items.shift(available))
|
110
|
+
|
111
|
+
self.signal unless self.empty?
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
100
115
|
def dequeue
|
101
116
|
item = super
|
102
117
|
|
data/lib/async/task.rb
CHANGED
@@ -230,18 +230,19 @@ module Async
|
|
230
230
|
private
|
231
231
|
|
232
232
|
# 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.
|
233
|
-
|
234
|
-
def fail!(exception = nil, propagate = true)
|
233
|
+
def fail!(exception = false, propagate = true)
|
235
234
|
@status = :failed
|
236
235
|
@result = exception
|
237
236
|
|
238
|
-
if
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
237
|
+
if exception
|
238
|
+
if propagate
|
239
|
+
raise exception
|
240
|
+
elsif @finished.nil?
|
241
|
+
# If no one has called wait, we log this as a warning:
|
242
|
+
Console.logger.warn(self, "Task may have ended with unhandled exception.", exception)
|
243
|
+
else
|
244
|
+
Console.logger.debug(self, exception)
|
245
|
+
end
|
245
246
|
end
|
246
247
|
end
|
247
248
|
|
data/lib/async/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.30.
|
4
|
+
version: 1.30.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: console
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.3.7
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: A concurrency framework for Ruby.
|