async 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e5f7f4cbc1cfc595409b58cfc0b74e2a2767837fc40bae5e1a1b60e7dcd3384
4
- data.tar.gz: 4eeb27d8248bc7993cf7758e41c8ffee3a54141d7c521e2a2805bbc8e8be3edd
3
+ metadata.gz: baad53560ae568056273aa5238c7ec0d3a0dec0d343e5740e6691f82670f4017
4
+ data.tar.gz: 3619eae563ec163639de135c3bd043e0d0c80fb3750211f5f37d27863cc21337
5
5
  SHA512:
6
- metadata.gz: d0b59a751dd4ea8cd7f2a83ad76fbf4dcff30ca11629d2e7f6ba18e017cf5de06880c1a6b19a3297967793e80394e10f8873ed24aa278d2019b11eb90a002394
7
- data.tar.gz: 1c23c709f983bc14ba1477b41b3ca7533275eb3464928c7d4d564e897fc2fb893617cde7bb6d1e90d050db9bbc1d1d2ed71c87da02e61cd559f0afef363fc567
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}:0x#{object_id.to_s(16)}#{@transient ? ' transient' : nil}"
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
@@ -34,7 +34,6 @@ module Async
34
34
  Fiber.set_scheduler(self)
35
35
  end
36
36
 
37
- alias with_timeout timeout_after
38
37
  public :sleep
39
38
  end
40
39
  end
@@ -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 timeout_after(timeout, exception = TimeoutError, message = "execution expired", &block)
285
+ def with_timeout(duration, exception = TimeoutError, message = "execution expired", &block)
286
286
  fiber = Fiber.current
287
287
 
288
- timer = @timers.after(timeout) do
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
- # @deprecated Replaced by {Scheduler#timeout_after}.
96
- def with_timeout(timeout, exception = TimeoutError, message = "execution expired", &block)
97
- Fiber.scheduler.timeout_after(timeout, exception, message, &block)
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
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Async
24
- VERSION = "2.0.0"
24
+ VERSION = "2.0.1"
25
25
  end
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.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: 2021-12-25 00:00:00.000000000 Z
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.0
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.3
200
+ rubygems_version: 3.3.8
184
201
  signing_key:
185
202
  specification_version: 4
186
203
  summary: A concurrency framework for Ruby.