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
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
{
2+
"originHash" : "109102968f72b508a09c97740fede846eb2bb9291019254db091bfbfbc0e073a",
23
"pins" : [
34
{
45
"identity" : "swift-docc-plugin",
56
"kind" : "remoteSourceControl",
67
"location" : "https://github.com/apple/swift-docc-plugin",
78
"state" : {
8-
"revision" : "3303b164430d9a7055ba484c8ead67a52f7b74f6",
9+
"revision" : "26ac5758409154cc448d7ab82389c520fa8a8247",
10+
"version" : "1.3.0"
11+
}
12+
},
13+
{
14+
"identity" : "swift-docc-symbolkit",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/apple/swift-docc-symbolkit",
17+
"state" : {
18+
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
919
"version" : "1.0.0"
1020
}
1121
}
1222
],
13-
"version" : 2
23+
"version" : 3
1424
}

README.md

+5-8
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

+1
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

+4-8
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

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

+2-2
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

+1-2
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

+1
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

+1
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)