async 2.15.1 → 2.15.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d69239cbc022fd8b50e28bac6356f037ae0ff221605f9309312b1b8566b61ac1
4
- data.tar.gz: ba47d3b3f2d50e4999eb219338ab9e3d619882c9b3de3b000c07a6f2dca89d21
3
+ metadata.gz: f7830bab72d5bdd68def8fe84b914785f191e29dc3f2d0b8f6d58d91878ff72d
4
+ data.tar.gz: c54b09d668152d3183ab8b366b75cc09c0e441a54914540896326e87b09a5fe7
5
5
  SHA512:
6
- metadata.gz: 6ddd53973722c47e13f92c93149cdc5a111af55af22a9d810aaddbe29fe6b996937737b929556dec48c22deab204d8113574892bb6f2095e991aea62a9188529
7
- data.tar.gz: 2c2c81505e97ebe5fe28fde6abe3eeed7641f5f6e4ead801432c31b60e85d378a6b823bcd97903d11cbfdd3f937f40e80ee288f0e6fb2c961884358c0d30c905
6
+ metadata.gz: 512e6fd4c720c19817bc95db9a7eb85f710314834cc655c9c1e43bac98831aab0802f9ef568de8e2308d1bb0a0304d6f3f4e2e8a465561ec20f79ac2644246d8
7
+ data.tar.gz: a0b8dae781660179da1a6ca0b766cbfdba8089684931cc95ea17e1dbf17667b96b34386e50fdceea97768af511dbbc6bbf90140c1027f53adc4db0a81e7d23bc
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/async/task.rb CHANGED
@@ -253,18 +253,18 @@ module Async
253
253
  return stopped!
254
254
  end
255
255
 
256
- # If we are deferring stop...
257
- if @defer_stop == false
258
- # Don't stop now... but update the state so we know we need to stop later.
259
- @defer_stop = true
260
- return false
261
- end
262
-
263
256
  # If the fiber is alive, we need to stop it:
264
257
  if @fiber&.alive?
265
258
  # As the task is now exiting, we want to ensure the event loop continues to execute until the task finishes.
266
259
  self.transient = false
267
260
 
261
+ # If we are deferring stop...
262
+ if @defer_stop == false
263
+ # Don't stop now... but update the state so we know we need to stop later.
264
+ @defer_stop = true
265
+ return false
266
+ end
267
+
268
268
  if self.current?
269
269
  # If the fiber is current, and later is `true`, we need to schedule the fiber to be stopped later, as it's currently invoking `stop`:
270
270
  if later
@@ -304,19 +304,23 @@ module Async
304
304
  # - false: defer_stop has been called and we are not stopping.
305
305
  # - true: defer_stop has been called and we will stop when exiting the block.
306
306
  if @defer_stop.nil?
307
- # If we are not deferring stop already, we can defer it now:
308
- @defer_stop = false
309
-
310
307
  begin
308
+ # If we are not deferring stop already, we can defer it now:
309
+ @defer_stop = false
310
+
311
311
  yield
312
312
  rescue Stop
313
313
  # If we are exiting due to a stop, we shouldn't try to invoke stop again:
314
314
  @defer_stop = nil
315
315
  raise
316
316
  ensure
317
+ defer_stop = @defer_stop
318
+
319
+ # We need to ensure the state is reset before we exit the block:
320
+ @defer_stop = nil
321
+
317
322
  # If we were asked to stop, we should do so now:
318
- if @defer_stop
319
- @defer_stop = nil
323
+ if defer_stop
320
324
  raise Stop, "Stopping current task (was deferred)!"
321
325
  end
322
326
  end
@@ -326,6 +330,11 @@ module Async
326
330
  end
327
331
  end
328
332
 
333
+ # @returns [Boolean] Whether stop has been deferred.
334
+ def stop_deferred?
335
+ @defer_stop
336
+ end
337
+
329
338
  # Lookup the {Task} for the current fiber. Raise `RuntimeError` if none is available.
330
339
  # @returns [Task]
331
340
  # @raises[RuntimeError] If task was not {set!} for the current fiber.
data/lib/async/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.15.1"
7
+ VERSION = "2.15.3"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.1
4
+ version: 2.15.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -63,7 +63,7 @@ cert_chain:
63
63
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
64
64
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
65
65
  -----END CERTIFICATE-----
66
- date: 2024-08-07 00:00:00.000000000 Z
66
+ date: 2024-08-08 00:00:00.000000000 Z
67
67
  dependencies:
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: console
metadata.gz.sig CHANGED
Binary file