Skip to content

Commit 45c0837

Browse files
authored
Merge pull request #1 from swhitty/swift-5.10
Swift 5.10
2 parents 3dd95cc + 66a14c9 commit 45c0837

File tree

5 files changed

+87
-22
lines changed

5 files changed

+87
-22
lines changed

.github/workflows/build.yml

+40-13
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
xcode_14_3:
10-
runs-on: macos-13
9+
xcode_15_2:
10+
runs-on: macos-14
1111
env:
12-
DEVELOPER_DIR: /Applications/Xcode_14.3.app/Contents/Developer
12+
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616
- name: Version
1717
run: swift --version
1818
- name: Build
@@ -22,30 +22,44 @@ jobs:
2222
- name: Gather code coverage
2323
run: xcrun llvm-cov export -format="lcov" .build/debug/AllocatedLockPackageTests.xctest/Contents/MacOS/AllocatedLockPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage_report.lcov
2424
- name: Upload Coverage
25-
uses: codecov/codecov-action@v3
25+
uses: codecov/codecov-action@v4
2626
with:
27+
token: ${{ secrets.CODECOV_TOKEN }}
2728
files: ./coverage_report.lcov
2829

29-
xcode_14_2:
30-
runs-on: macos-12
30+
xcode_14_3_1:
31+
runs-on: macos-13
3132
env:
32-
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
33+
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
- name: Version
38+
run: swift --version
39+
- name: Build
40+
run: swift build --build-tests
41+
- name: Test
42+
run: swift test
43+
44+
linux_swift_5_10:
45+
runs-on: ubuntu-latest
46+
container: swift:5.8
3347
steps:
3448
- name: Checkout
35-
uses: actions/checkout@v3
49+
uses: actions/checkout@v4
3650
- name: Version
3751
run: swift --version
3852
- name: Build
3953
run: swift build --build-tests
4054
- name: Test
4155
run: swift test --skip-build
4256

43-
linux_swift_5_7:
57+
linux_swift_5_9:
4458
runs-on: ubuntu-latest
45-
container: swift:5.7
59+
container: swift:5.8
4660
steps:
4761
- name: Checkout
48-
uses: actions/checkout@v3
62+
uses: actions/checkout@v4
4963
- name: Version
5064
run: swift --version
5165
- name: Build
@@ -58,7 +72,20 @@ jobs:
5872
container: swift:5.8
5973
steps:
6074
- name: Checkout
61-
uses: actions/checkout@v3
75+
uses: actions/checkout@v4
76+
- name: Version
77+
run: swift --version
78+
- name: Build
79+
run: swift build --build-tests
80+
- name: Test
81+
run: swift test --skip-build
82+
83+
linux_swift_5_7:
84+
runs-on: ubuntu-latest
85+
container: swift:5.7
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@v4
6289
- name: Version
6390
run: swift --version
6491
- name: Build

Package@swift-5.8.swift

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// swift-tools-version:5.8
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "AllocatedLock",
7+
platforms: [
8+
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
9+
],
10+
products: [
11+
.library(
12+
name: "AllocatedLock",
13+
targets: ["AllocatedLock"]
14+
)
15+
],
16+
targets: [
17+
.target(
18+
name: "AllocatedLock",
19+
path: "Sources",
20+
swiftSettings: .upcomingFeatures
21+
),
22+
.testTarget(
23+
name: "AllocatedLockTests",
24+
dependencies: ["AllocatedLock"],
25+
path: "Tests",
26+
swiftSettings: .upcomingFeatures
27+
)
28+
]
29+
)
30+
31+
extension Array where Element == SwiftSetting {
32+
33+
static var upcomingFeatures: [SwiftSetting] {
34+
[
35+
.enableExperimentalFeature("StrictConcurrency")
36+
]
37+
}
38+
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Build](https://github.com/swhitty/AllocatedLock/actions/workflows/build.yml/badge.svg)](https://github.com/swhitty/AllocatedLock/actions/workflows/build.yml)
22
[![Codecov](https://codecov.io/gh/swhitty/AllocatedLock/graphs/badge.svg)](https://codecov.io/gh/swhitty/AllocatedLock)
33
[![Platforms](https://img.shields.io/badge/platforms-iOS%20|%20Mac%20|%20tvOS%20|%20Linux%20|%20Windows-lightgray.svg)](https://github.com/swhitty/AllocatedLock/blob/main/Package.swift)
4-
[![Swift 5.8](https://img.shields.io/badge/swift-5.7%20–%205.8-red.svg?style=flat)](https://developer.apple.com/swift)
4+
[![Swift 5.10](https://img.shields.io/badge/swift-5.7%20–%205.10-red.svg?style=flat)](https://developer.apple.com/swift)
55
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
66
[![Twitter](https://img.shields.io/badge/twitter-@simonwhitty-blue.svg)](http://twitter.com/simonwhitty)
77

Sources/AllocatedLock.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131

3232
// Backports the Swift interface around os_unfair_lock_t available in recent Darwin platforms
3333
//
34-
@available(iOS, deprecated: 16.0, message: "use OSAllocatedUnfairLock directly")
35-
@available(tvOS, deprecated: 16.0, message: "use OSAllocatedUnfairLock directly")
36-
@available(watchOS, deprecated: 9, message: "use OSAllocatedUnfairLock directly")
37-
@available(macOS, deprecated: 13.0, message: "use OSAllocatedUnfairLock directly")
3834
public struct AllocatedLock<State>: @unchecked Sendable {
3935

4036
@usableFromInline
@@ -78,7 +74,10 @@ public extension AllocatedLock where State == Void {
7874

7975
#if canImport(Darwin)
8076

81-
@_implementationOnly import os
77+
import struct os.os_unfair_lock_t
78+
import struct os.os_unfair_lock
79+
import func os.os_unfair_lock_lock
80+
import func os.os_unfair_lock_unlock
8281

8382
extension AllocatedLock {
8483
@usableFromInline

Tests/AllocatedLockTests.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ final class AllocatedLockTests: XCTestCase {
5656
XCTAssertTrue(value)
5757
}
5858

59-
@MainActor
6059
func testLock_Blocks() async {
6160
let lock = AllocatedLock()
62-
lock.unsafeLock()
6361

64-
Task {
62+
Task { @MainActor in
63+
lock.unsafeLock()
6564
try? await Task.sleep(nanoseconds: 1_000_000_000)
6665
lock.unsafeUnlock()
6766
}
6867

68+
try? await Task.sleep(nanoseconds: 500_000)
69+
6970
let results = await withTaskGroup(of: Bool.self) { group in
7071
group.addTask {
7172
try? await Task.sleep(nanoseconds: 5_000_000)

0 commit comments

Comments
 (0)