Commit 335de7f
taca
devel/ruby-async: update to 2.34.0
2.33.0 (2025-09-29)
* Introduce Async::Promise.fulfill for optional promise resolution.
2.34.0 (2025-10-08)
Kernel::Barrier Convenience Interface
Starting multiple concurrent tasks and waiting for them to finish is a
common pattern. This change introduces a small ergonomic helper, Barrier,
defined in Kernel, that encapsulates this behavior: it creates an
Async::Barrier, yields it to a block, waits for completion (using Sync to
run a reactor if needed), and ensures remaining tasks are stopped on exit.
require 'async'
Barrier do |barrier|
3.times do |i|
barrier.async do |task|
sleep(rand * 0.1) # Simulate work
puts "Task #{i} completed"
end
end
end
# All tasks are guaranteed to complete or be stopped when the block exits.
If an exception is raised by a task, it will be propagated to the caller,
and any remaining tasks will be stopped. The parent: parameter can be used
to specify a parent task for the barrier, otherwise it will use the current
task if available, or create a new reactor if not.1 parent 4d3aefc commit 335de7f
3 files changed
Lines changed: 9 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments