Skip to content

Commit 9564134

Browse files
committed
Bump minor version.
1 parent c03096c commit 9564134

File tree

4 files changed

+54
-17
lines changed

4 files changed

+54
-17
lines changed

context/getting-started.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ Async::Safe.enable!
2525

2626
When a violation is detected, an `Async::Safe::ViolationError` will be raised immediately with details about the object, method, and execution contexts involved.
2727

28-
### Single-Owner Model
28+
### Single-Owner Model (Opt-In)
2929

30-
By default, all objects are assumed to follow a **single-owner model** - they should only be accessed from one fiber/thread at a time:
30+
By default, all classes are assumed to be async-safe. To enable tracking for specific classes, mark them with `ASYNC_SAFE = false`:
3131

3232
~~~ ruby
3333
class MyBody
34+
ASYNC_SAFE = false # Enable tracking for this class
35+
3436
def initialize(chunks)
3537
@chunks = chunks
3638
@index = 0
@@ -90,15 +92,29 @@ class MyQueue
9092
end
9193
~~~
9294

93-
### Marking Async-Safe Methods
95+
Or use a hash for per-method configuration:
96+
97+
~~~ ruby
98+
class MixedClass
99+
ASYNC_SAFE = {
100+
read: true, # This method is async-safe
101+
write: false # This method is NOT async-safe
102+
}.freeze
103+
104+
# ... implementation
105+
end
106+
~~~
107+
108+
### Marking Methods with Hash
94109

95-
Mark specific methods as async-safe:
110+
Use a hash to specify which methods are async-safe:
96111

97112
~~~ ruby
98113
class MixedSafety
99-
include Async::Safe
100-
101-
async_safe :safe_read
114+
ASYNC_SAFE = {
115+
safe_read: true, # This method is async-safe
116+
increment: false # This method is NOT async-safe
117+
}.freeze
102118

103119
def initialize(data)
104120
@data = data
@@ -110,7 +126,7 @@ class MixedSafety
110126
end
111127

112128
def increment
113-
@count += 1 # Not async-safe
129+
@count += 1 # Not async-safe - will be tracked
114130
end
115131
end
116132

@@ -122,6 +138,17 @@ Fiber.schedule do
122138
end
123139
~~~
124140

141+
Or use an array to list async-safe methods:
142+
143+
~~~ ruby
144+
class MyClass
145+
ASYNC_SAFE = [:read, :inspect].freeze
146+
147+
# read and inspect are async-safe
148+
# all other methods will be tracked
149+
end
150+
~~~
151+
125152
### Transferring Ownership
126153

127154
Explicitly transfer ownership between fibers:

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.2.0"
8+
VERSION = "0.3.0"
99
end
1010
end
1111

readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ 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.3.0
26+
27+
- Inverted default model: classes are async-safe by default, use `ASYNC_SAFE = false` to enable tracking.
28+
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
29+
- Added `Class#async_safe!` method for marking classes.
30+
- Added `Class#async_safe?(method)` method for querying safety.
31+
- Removed logger feature: always raises `ViolationError` exceptions.
32+
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
33+
- Removed `reset!` method: use `disable!` + `enable!` instead.
34+
2535
### v0.2.0
2636

2737
- `Thread::Queue` transfers ownership of objects popped from it.

releases.md

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

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

5-
- Inverted default model: classes are async-safe by default, use `ASYNC_SAFE = false` to enable tracking.
6-
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
7-
- Added `Class#async_safe!` method for marking classes.
8-
- Added `Class#async_safe?(method)` method for querying safety.
9-
- Removed logger feature: always raises `ViolationError` exceptions.
10-
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
11-
- Removed `reset!` method: use `disable!` + `enable!` instead.
5+
- Inverted default model: classes are async-safe by default, use `ASYNC_SAFE = false` to enable tracking.
6+
- Added flexible `ASYNC_SAFE` constant support: boolean, hash, or array configurations.
7+
- Added `Class#async_safe!` method for marking classes.
8+
- Added `Class#async_safe?(method)` method for querying safety.
9+
- Removed logger feature: always raises `ViolationError` exceptions.
10+
- Removed `Async::Safe::Concurrent` module: use `async_safe!` instead.
11+
- Removed `reset!` method: use `disable!` + `enable!` instead.
1212

1313
## v0.2.0
1414

0 commit comments

Comments
 (0)