Skip to content

Commit

Permalink
Support Swift 6 (#34)
Browse files Browse the repository at this point in the history
* Support Swift 6

* Mention that Swift 6 fixes the core problem
  • Loading branch information
dfed committed Jun 28, 2024
1 parent f1775d4 commit 6c2239a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 35 additions & 0 deletions Package@swift-6.0.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "swift-async-queue",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
.visionOS(.v1),
],
products: [
.library(
name: "AsyncQueue",
targets: ["AsyncQueue"]),
],
targets: [
.target(
name: "AsyncQueue",
dependencies: [],
swiftSettings: [
.swiftLanguageVersion(.v6),
]),
.testTarget(
name: "AsyncQueueTests",
dependencies: ["AsyncQueue"],
swiftSettings: [
.swiftLanguageVersion(.v6),
]),
]
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A library of queues that enable sending ordered tasks from synchronous to asynch

## Task Ordering and Swift Concurrency

Tasks sent from a synchronous context to an asynchronous context in Swift Concurrency are inherently unordered. Consider the following test:
Tasks sent from a synchronous context to an asynchronous context in Swift Concurrency prior to Swift 6 are inherently unordered. Consider the following test:

```swift
@MainActor
Expand Down Expand Up @@ -40,7 +40,7 @@ func testMainActorTaskOrdering() async {

Despite the spawned `Task` inheriting the serial `@MainActor` execution context, the ordering of the scheduled asynchronous work is not guaranteed.

While [actors](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html#ID645) are great at serializing tasks, there is no simple way in the standard Swift library to send ordered tasks to them from a synchronous context.
While [actors](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html#ID645) are great at serializing tasks, there is no simple way in the standard Swift library prior to Swift 6 to send ordered tasks to them from a synchronous context.

### Executing asynchronous tasks in FIFO order

Expand Down

0 comments on commit 6c2239a

Please sign in to comment.