async 2.0.0 → 2.0.1
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
- data/lib/async/node.rb +1 -1
- data/lib/async/reactor.rb +0 -1
- data/lib/async/scheduler.rb +8 -2
- data/lib/async/task.rb +3 -3
- data/lib/async/version.rb +1 -1
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baad53560ae568056273aa5238c7ec0d3a0dec0d343e5740e6691f82670f4017
|
4
|
+
data.tar.gz: 3619eae563ec163639de135c3bd043e0d0c80fb3750211f5f37d27863cc21337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51073edec2fd7249c023490dacbae3a06a65d474495837bb423eff9e23d0fe24885dc43a996dfe325b80869ef79081d8a2ae20f148fbefc95076fea9fb3d5fcf
|
7
|
+
data.tar.gz: fee5ce5b5ac2c607d47b7371c6db705d51c9a7a66c3dccb31472f8002cde31f1d2710ab009b3d0700f5ee9c4a69d597761700b94b9547af40605c933383918b2
|
data/lib/async/node.rb
CHANGED
@@ -218,7 +218,7 @@ module Async
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def description
|
221
|
-
@object_name ||= "#{self.class}
|
221
|
+
@object_name ||= "#{self.class}:#{format '%#018x', object_id}#{@transient ? ' transient' : nil}"
|
222
222
|
|
223
223
|
if @annotation
|
224
224
|
"#{@object_name} #{@annotation}"
|
data/lib/async/reactor.rb
CHANGED
data/lib/async/scheduler.rb
CHANGED
@@ -282,10 +282,10 @@ module Async
|
|
282
282
|
|
283
283
|
# Invoke the block, but after the specified timeout, raise {TimeoutError} in any currenly blocking operation. If the block runs to completion before the timeout occurs or there are no non-blocking operations after the timeout expires, the code will complete without any exception.
|
284
284
|
# @parameter duration [Numeric] The time in seconds, in which the task should complete.
|
285
|
-
def
|
285
|
+
def with_timeout(duration, exception = TimeoutError, message = "execution expired", &block)
|
286
286
|
fiber = Fiber.current
|
287
287
|
|
288
|
-
timer = @timers.after(
|
288
|
+
timer = @timers.after(duration) do
|
289
289
|
if fiber.alive?
|
290
290
|
fiber.raise(exception, message)
|
291
291
|
end
|
@@ -295,5 +295,11 @@ module Async
|
|
295
295
|
ensure
|
296
296
|
timer.cancel if timer
|
297
297
|
end
|
298
|
+
|
299
|
+
def timeout_after(duration, exception, message, &block)
|
300
|
+
with_timeout(duration, exception, message) do |timer|
|
301
|
+
yield duration
|
302
|
+
end
|
303
|
+
end
|
298
304
|
end
|
299
305
|
end
|
data/lib/async/task.rb
CHANGED
@@ -92,9 +92,9 @@ module Async
|
|
92
92
|
super
|
93
93
|
end
|
94
94
|
|
95
|
-
#
|
96
|
-
def with_timeout(
|
97
|
-
Fiber.scheduler.
|
95
|
+
# Execute the given block of code, raising the specified exception if it exceeds the given duration during a non-blocking operation.
|
96
|
+
def with_timeout(duration, exception = TimeoutError, message = "execution expired", &block)
|
97
|
+
Fiber.scheduler.with_timeout(duration, exception, message, &block)
|
98
98
|
end
|
99
99
|
|
100
100
|
# Yield back to the reactor and allow other fibers to execute.
|
data/lib/async/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,31 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Devin Christensen
|
9
|
+
- Bruno Sutic
|
10
|
+
- Jeremy Jung
|
11
|
+
- Kent Gruber
|
12
|
+
- jeremyjung
|
13
|
+
- Brian Morearty
|
14
|
+
- Jiang Jinyang
|
15
|
+
- Julien Portalier
|
16
|
+
- Olle Jonsson
|
17
|
+
- Patrik Wenger
|
18
|
+
- Ryan Musgrave
|
19
|
+
- Salim Semaoune
|
20
|
+
- Shannon Skipper
|
21
|
+
- Sokolov Yura aka funny_falcon
|
22
|
+
- Stefan Wrobel
|
23
|
+
- jasl
|
24
|
+
- muryoimpl
|
8
25
|
autorequire:
|
9
26
|
bindir: bin
|
10
27
|
cert_chain: []
|
11
|
-
date:
|
28
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
12
29
|
dependencies:
|
13
30
|
- !ruby/object:Gem::Dependency
|
14
31
|
name: console
|
@@ -173,14 +190,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
190
|
requirements:
|
174
191
|
- - ">="
|
175
192
|
- !ruby/object:Gem::Version
|
176
|
-
version: 3.1.
|
193
|
+
version: 3.1.1
|
177
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
195
|
requirements:
|
179
196
|
- - ">="
|
180
197
|
- !ruby/object:Gem::Version
|
181
198
|
version: '0'
|
182
199
|
requirements: []
|
183
|
-
rubygems_version: 3.3.
|
200
|
+
rubygems_version: 3.3.8
|
184
201
|
signing_key:
|
185
202
|
specification_version: 4
|
186
203
|
summary: A concurrency framework for Ruby.
|