Skip to content

Commit d352311

Browse files
committed
Bump minor version.
1 parent faa289a commit d352311

File tree

4 files changed

+50
-11
lines changed

4 files changed

+50
-11
lines changed

context/getting-started.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,38 @@ Fiber.schedule do
163163
end
164164
~~~
165165

166+
### Deep Transfer with Traversal
167+
168+
By default, `transfer` only transfers the object itself (shallow). For collections like `Array`, `Hash`, and `Set`, the gem automatically traverses and transfers contained objects:
169+
170+
~~~ ruby
171+
bodies = [Body.new, Body.new]
172+
173+
Async::Safe.transfer(bodies) # Transfers array AND all bodies inside
174+
~~~
175+
176+
Custom classes can define traversal behavior using `async_safe_traverse`:
177+
178+
~~~ ruby
179+
class Request
180+
async_safe!(false)
181+
attr_accessor :body, :headers
182+
183+
def self.async_safe_traverse(instance, &block)
184+
yield instance.body
185+
yield instance.headers
186+
end
187+
end
188+
189+
request = Request.new
190+
request.body = Body.new
191+
request.headers = Headers.new
192+
193+
Async::Safe.transfer(request) # Transfers request, body, AND headers.
194+
~~~
195+
196+
**Note:** Shareable objects (`async_safe? -> true`) are never traversed or transferred, as they can be safely shared across fibers.
197+
166198
## Integration with Tests
167199

168200
Add to your test helper (e.g., `config/sus.rb` or `spec/spec_helper.rb`):

lib/async/safe/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module Async
77
module Safe
8-
VERSION = "0.3.2"
8+
VERSION = "0.4.0"
99
end
1010
end
1111

readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Please see the [project documentation](https://socketry.github.io/async-safe/) f
2222

2323
Please see the [project releases](https://socketry.github.io/async-safe/releases/index) for all releases.
2424

25+
### v0.4.0
26+
27+
- Improved `Async::Safe.transfer` to recursively transfer ownership of tracked instance variables.
28+
2529
### v0.3.2
2630

2731
- Better error message.
@@ -32,6 +36,9 @@ Please see the [project releases](https://socketry.github.io/async-safe/releases
3236
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
3337
- Added `Class#async_safe!` method for marking classes.
3438
- Added `Class#async_safe?(method)` method for querying safety.
39+
- Added `Class.async_safe_traverse` for custom deep transfer traversal (opt-in).
40+
- Improved `Async::Safe.transfer` to use shallow transfer by default with opt-in deep traversal.
41+
- Mark built-in collections (`Array`, `Hash`, `Set`) as single-owner with deep traversal support.
3542
- Removed logger feature: always raises `ViolationError` exceptions.
3643
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
3744

releases.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Releases
22

3-
## Unreleased
3+
## v0.4.0
44

55
- Improved `Async::Safe.transfer` to recursively transfer ownership of tracked instance variables.
66

@@ -10,15 +10,15 @@
1010

1111
## v0.3.0
1212

13-
- Inverted default model: classes are async-safe by default, use `ASYNC_SAFE = false` to enable tracking.
14-
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
15-
- Added `Class#async_safe!` method for marking classes.
16-
- Added `Class#async_safe?(method)` method for querying safety.
17-
- Added `Class.async_safe_traverse` for custom deep transfer traversal (opt-in).
18-
- Improved `Async::Safe.transfer` to use shallow transfer by default with opt-in deep traversal.
19-
- Mark built-in collections (`Array`, `Hash`, `Set`) as single-owner with deep traversal support.
20-
- Removed logger feature: always raises `ViolationError` exceptions.
21-
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
13+
- Inverted default model: classes are async-safe by default, use `ASYNC_SAFE = false` to enable tracking.
14+
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
15+
- Added `Class#async_safe!` method for marking classes.
16+
- Added `Class#async_safe?(method)` method for querying safety.
17+
- Added `Class.async_safe_traverse` for custom deep transfer traversal (opt-in).
18+
- Improved `Async::Safe.transfer` to use shallow transfer by default with opt-in deep traversal.
19+
- Mark built-in collections (`Array`, `Hash`, `Set`) as single-owner with deep traversal support.
20+
- Removed logger feature: always raises `ViolationError` exceptions.
21+
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
2222

2323
## v0.2.0
2424

0 commit comments

Comments
 (0)