Skip to content

Commit 675c56c

Browse files
authored
Deprecate ActorIsolated. (#29)
1 parent d7eac73 commit 675c56c

File tree

9 files changed

+41
-22
lines changed

9 files changed

+41
-22
lines changed

ConcurrencyExtras.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Reliably testable Swift concurrency.
99

1010
* [Motivation](#motivation)
11-
* [`ActorIsolated` and `LockIsolated`](#actorisolated-and-lockisolated)
11+
* [`LockIsolated`](#lockisolated)
1212
* [Streams](#streams)
1313
* [Tasks](#tasks)
1414
* [Serial execution](#serial-execution)
@@ -34,19 +34,16 @@ You can watch all of the episodes [here](https://www.pointfree.co/collections/co
3434
This library comes with a number of tools that make working with Swift concurrency easier and more
3535
testable.
3636

37-
* [`ActorIsolated` and `LockIsolated`](#actorisolated-and-lockisolated)
37+
* [`LockIsolated`](#lockisolated)
3838
* [Streams](#streams)
3939
* [Tasks](#tasks)
4040
* [`UncheckedSendable`](#uncheckedsendable)
4141
* [Serial execution](#serial-execution)
4242

43-
### `ActorIsolated` and `LockIsolated`
43+
### LockIsolated`
4444

45-
The `ActorIsolated` and `LockIsolated` types help wrap other values in an isolated context.
46-
`ActorIsolated` wraps the value in an actor so that the only way to access and mutate the value is
47-
through an async/await interface. `LockIsolated` wraps the value in a class with a lock, which
48-
allows you to read and write the value with a synchronous interface. You should prefer to use
49-
`ActorIsolated` when you have access to an asynchronous context.
45+
The `LockIsolated` type helps wrap other values in an isolated context. It wraps the value in a
46+
class with a lock, which allows you to read and write the value with a synchronous interface.
5047

5148
### Streams
5249

Sources/ConcurrencyExtras/ActorIsolated.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
/// ```
4141
///
4242
/// To synchronously isolate a value, see ``LockIsolated``.
43+
@available(*, deprecated, message: "Use 'LockIsolated' instead.")
4344
public final actor ActorIsolated<Value> {
4445
/// The actor-isolated value.
4546
public var value: Value

Sources/ConcurrencyExtras/Documentation.docc/ConcurrencyExtras.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ Useful, testable Swift concurrency.
77
This library comes with a number of tools that make working with Swift concurrency easier and more
88
testable.
99

10-
### ActorIsolated and LockIsolated
10+
### LockIsolated
1111

12-
The ``ActorIsolated`` and ``LockIsolated`` types help wrap other values in an isolated context.
13-
`ActorIsolated` wraps the value in an actor so that the only way to access and mutate the value is
14-
through an async/await interface. ``LockIsolated`` wraps the value in a class with a lock, which
15-
allows you to read and write the value with a synchronous interface. You should prefer to use
16-
`ActorIsolated` when you have access to an asynchronous context.
12+
The `LockIsolated` type helps wrap other values in an isolated context. It wraps the value in a
13+
class with a lock, which allows you to read and write the value with a synchronous interface.
1714

1815
### Streams
1916

@@ -238,13 +235,12 @@ need to make weaker assertions due to non-determinism, but can still assert on s
238235

239236
### Data races
240237

241-
- ``ActorIsolated``
242238
- ``LockIsolated``
243239

244240
### Serial execution
245241

246242
- <doc:ReliablyTestingAsync>
247-
- ``withMainSerialExecutor(operation:)-79jpc``
243+
- ``withMainSerialExecutor(operation:)-5wq73``
248244

249245
### Preconcurrency
250246

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Deprecations
2+
3+
Review unsupported reducer APIs and their replacements.
4+
5+
## Overview
6+
7+
Avoid using deprecated APIs in your app. Select a method to see the replacement that you should use
8+
instead.
9+
10+
## Topics
11+
12+
### Case path deprecations
13+
14+
- ``ActorIsolated``

Sources/ConcurrencyExtras/LockIsolated.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import Foundation
22

33
/// A generic wrapper for isolating a mutable value with a lock.
44
///
5-
/// To asynchronously isolate a value on an actor, see ``ActorIsolated``. If you trust the
6-
/// sendability of the underlying value, consider using ``UncheckedSendable``, instead.
5+
/// If you trust the sendability of the underlying value, consider using ``UncheckedSendable``,
6+
/// instead.
77
@dynamicMemberLookup
88
public final class LockIsolated<Value>: @unchecked Sendable {
99
private var _value: Value

Sources/ConcurrencyExtras/UncheckedSendable.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
/// > that the type is safe to use from multiple threads, and the compiler cannot help you find
1111
/// > potential race conditions in your code.
1212
///
13-
/// To synchronously isolate a value with a lock, see ``LockIsolated``. To asynchronously isolated a
14-
/// value on an actor, see ``ActorIsolated``.
13+
/// To synchronously isolate a value with a lock, see ``LockIsolated``.
1514
#if swift(>=5.10)
1615
@available(iOS, deprecated: 9999, message: "Use 'nonisolated(unsafe) let', instead.")@available(
1716
macOS, deprecated: 9999, message: "Use 'nonisolated(unsafe) let', instead."

Tests/ConcurrencyExtrasTests/ActorIsolatedTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ConcurrencyExtras
22
import XCTest
33

4+
@available(*, deprecated)
45
final class ActorIsolatedTests: XCTestCase {
56
func testAsyncWithValue() async {
67
let numbers = ActorIsolated<Set<Int>>([])

Tests/ConcurrencyExtrasTests/MainSerialExecutorTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
XCTAssertEqual(Array(1...1000), xs.value)
1818
}
1919

20+
@available(*, deprecated)
2021
func testSerializedExecution_WithActor() async {
2122
let xs = ActorIsolated<[Int]>([])
2223
await withMainSerialExecutor {

0 commit comments

Comments
 (0)