Skip to content

Commit 5922b00

Browse files
committed
Add release notes.
1 parent 9278f3f commit 5922b00

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

releases.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Releases
22

3+
## Unreleased
4+
5+
### `Kernel::Barrier` Convenience Interface
6+
7+
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.
8+
9+
``` ruby
10+
require 'async'
11+
12+
Barrier do |barrier|
13+
3.times do |i|
14+
barrier.async do |task|
15+
sleep(rand * 0.1) # Simulate work
16+
puts "Task #{i} completed"
17+
end
18+
end
19+
end
20+
21+
# All tasks are guaranteed to complete or be stopped when the block exits.
22+
```
23+
24+
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.
25+
326
## v2.33.0
427

528
- Introduce `Async::Promise.fulfill` for optional promise resolution.

0 commit comments

Comments
 (0)