Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Reliably testable Swift concurrency.

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

* [`ActorIsolated` and `LockIsolated`](#actorisolated-and-lockisolated)
* [`LockIsolated`](#lockisolated)
* [Streams](#streams)
* [Tasks](#tasks)
* [`UncheckedSendable`](#uncheckedsendable)
* [Serial execution](#serial-execution)

### `ActorIsolated` and `LockIsolated`
### LockIsolated`

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

### Streams

Expand Down
1 change: 1 addition & 0 deletions Sources/ConcurrencyExtras/ActorIsolated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
/// ```
///
/// To synchronously isolate a value, see ``LockIsolated``.
@available(*, deprecated, message: "Use 'LockIsolated' instead.")
public final actor ActorIsolated<Value> {
/// The actor-isolated value.
public var value: Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ Useful, testable Swift concurrency.
This library comes with a number of tools that make working with Swift concurrency easier and more
testable.

### ActorIsolated and LockIsolated
### LockIsolated

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

### Streams

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

### Data races

- ``ActorIsolated``
- ``LockIsolated``

### Serial execution

- <doc:ReliablyTestingAsync>
- ``withMainSerialExecutor(operation:)-79jpc``
- ``withMainSerialExecutor(operation:)-5wq73``

### Preconcurrency

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Deprecations

Review unsupported reducer APIs and their replacements.

## Overview

Avoid using deprecated APIs in your app. Select a method to see the replacement that you should use
instead.

## Topics

### Case path deprecations

- ``ActorIsolated``
4 changes: 2 additions & 2 deletions Sources/ConcurrencyExtras/LockIsolated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Foundation

/// A generic wrapper for isolating a mutable value with a lock.
///
/// To asynchronously isolate a value on an actor, see ``ActorIsolated``. If you trust the
/// sendability of the underlying value, consider using ``UncheckedSendable``, instead.
/// If you trust the sendability of the underlying value, consider using ``UncheckedSendable``,
/// instead.
@dynamicMemberLookup
public final class LockIsolated<Value>: @unchecked Sendable {
private var _value: Value
Expand Down
3 changes: 1 addition & 2 deletions Sources/ConcurrencyExtras/UncheckedSendable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
/// > that the type is safe to use from multiple threads, and the compiler cannot help you find
/// > potential race conditions in your code.
///
/// To synchronously isolate a value with a lock, see ``LockIsolated``. To asynchronously isolated a
/// value on an actor, see ``ActorIsolated``.
/// To synchronously isolate a value with a lock, see ``LockIsolated``.
#if swift(>=5.10)
@available(iOS, deprecated: 9999, message: "Use 'nonisolated(unsafe) let', instead.")@available(
macOS, deprecated: 9999, message: "Use 'nonisolated(unsafe) let', instead."
Expand Down
1 change: 1 addition & 0 deletions Tests/ConcurrencyExtrasTests/ActorIsolatedTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ConcurrencyExtras
import XCTest

@available(*, deprecated)
final class ActorIsolatedTests: XCTestCase {
func testAsyncWithValue() async {
let numbers = ActorIsolated<Set<Int>>([])
Expand Down
1 change: 1 addition & 0 deletions Tests/ConcurrencyExtrasTests/MainSerialExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
XCTAssertEqual(Array(1...1000), xs.value)
}

@available(*, deprecated)
func testSerializedExecution_WithActor() async {
let xs = ActorIsolated<[Int]>([])
await withMainSerialExecutor {
Expand Down