async 2.38.1 → 2.39.0

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: 775f7308b78b3544dca24cb0db4c79bbb952fc6446c25bb77e8edb78ece4a090
4
- data.tar.gz: dfbb05706b19dd0b47269d73dc6acb28194ef9ff4b9ce6c9d7e19eb30ccf9170
3
+ metadata.gz: 1d8427e86e8ab22c81e41dd6e7df7bd79087e3fa72ce786f07ae7b65d9d94545
4
+ data.tar.gz: 30e9e7e88b211aa21afe844e3f9510b5af39d2b4af1d97710ce533f581b5c57b
5
5
  SHA512:
6
- metadata.gz: 02f8bb5e3e57798f7af1901ea1b6fdab323a957634f2b8bb644cc5942dc32d5808cbce18eb68953ba6e2e764c861c040705821e690ae3dd09f902f5d9e25e3b5
7
- data.tar.gz: fe7e1c8fc1d166a6d8c55b1c1fb56645db4b742c9203392b6fb668ca58d50d65303f2998077363a83078f2ab0fd9429d097ea86d8013eb22a43eb2a275262305
6
+ metadata.gz: 337694b65547afc0d4c1568a02c0c08d03d0d70a8b2319b9b9a77660ad9f37c82ff3ab49a3856ebee477657df6b254d62e59ca6b31e9312484c02e696deab007
7
+ data.tar.gz: e9bc3a1a27f9ba9ea6004dee40df9b385d7959c30e7059521805e91d1f64e9ed16bbc0920b4eb3b1dae8a727ab52ed8258f95bb2605e219f311920bf3fe2b031
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/async/barrier.rb CHANGED
@@ -81,12 +81,17 @@ module Async
81
81
  # Wait for all tasks to complete by invoking {Task#wait} on each waiting task, which may raise an error. As long as the task has completed, it will be removed from the barrier.
82
82
  #
83
83
  # @yields {|task| ...} If a block is given, the unwaited task is yielded. You must invoke {Task#wait} yourself. In addition, you may `break` if you have captured enough results.
84
+ # @returns [Integer | Nil] The number of tasks which were waited for, or `nil` if there were no tasks to wait for.
84
85
  #
85
86
  # @asynchronous Will wait for tasks to finish executing.
86
87
  def wait
87
- while !@tasks.empty?
88
+ return nil if @tasks.empty?
89
+ count = 0
90
+
91
+ while true
88
92
  # Wait for a task to finish (we get the task node):
89
- return unless waiting = @finished.wait
93
+ break unless waiting = @finished.wait
94
+ count += 1
90
95
 
91
96
  # Remove the task as it is now finishing:
92
97
  @tasks.remove?(waiting)
@@ -101,7 +106,11 @@ module Async
101
106
  # Wait for it to either complete or raise an error:
102
107
  task.wait
103
108
  end
109
+
110
+ break if @tasks.empty?
104
111
  end
112
+
113
+ return count
105
114
  end
106
115
 
107
116
  # Cancel all tasks held by the barrier.
data/lib/async/task.rb CHANGED
@@ -456,6 +456,9 @@ module Async
456
456
 
457
457
  # Finish the current task, moving any children to the parent.
458
458
  def finish!
459
+ # Break the cycle:
460
+ @fiber&.async_task = nil
461
+
459
462
  # Don't hold references to the fiber or block after the task has finished:
460
463
  @fiber = nil
461
464
  @block = nil # If some how we went directly from initialized to finished.
data/lib/async/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Async
8
- VERSION = "2.38.1"
8
+ VERSION = "2.39.0"
9
9
  end
data/readme.md CHANGED
@@ -35,6 +35,10 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
35
35
 
36
36
  Please see the [project releases](https://socketry.github.io/async/releases/index) for all releases.
37
37
 
38
+ ### v2.39.0
39
+
40
+ - `Async::Barrier#wait` now returns the number of tasks that were waited for, or `nil` if there were no tasks to wait for. This provides better feedback about the operation, and allows you to know how many tasks were involved in the wait.
41
+
38
42
  ### v2.38.1
39
43
 
40
44
  - Fix `Barrier#async` when `parent.async` yields before the child block executes. Previously, `Barrier#wait` could return early and miss tracking the task entirely, because the task had not yet appended itself to the barrier's task list.
@@ -75,10 +79,6 @@ Please see the [project releases](https://socketry.github.io/async/releases/inde
75
79
 
76
80
  - [`Kernel::Barrier` Convenience Interface](https://socketry.github.io/async/releases/index#kernel::barrier-convenience-interface)
77
81
 
78
- ### v2.33.0
79
-
80
- - Introduce `Async::Promise.fulfill` for optional promise resolution.
81
-
82
82
  ## See Also
83
83
 
84
84
  - [async-http](https://github.com/socketry/async-http) — Asynchronous HTTP client/server.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v2.39.0
4
+
5
+ - `Async::Barrier#wait` now returns the number of tasks that were waited for, or `nil` if there were no tasks to wait for. This provides better feedback about the operation, and allows you to know how many tasks were involved in the wait.
6
+
3
7
  ## v2.38.1
4
8
 
5
9
  - Fix `Barrier#async` when `parent.async` yields before the child block executes. Previously, `Barrier#wait` could return early and miss tracking the task entirely, because the task had not yet appended itself to the barrier's task list.
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.38.1
4
+ version: 2.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 4.0.3
219
+ rubygems_version: 3.6.9
220
220
  specification_version: 4
221
221
  summary: A concurrency framework for Ruby.
222
222
  test_files: []
metadata.gz.sig CHANGED
Binary file