File tree Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Expand file tree Collapse file tree 3 files changed +27
-26
lines changed Original file line number Diff line number Diff line change 3030//
3131
3232// Backports the Swift 6 type Mutex<Value> to all Darwin platforms
33- // @available(SwiftStdlib 6.0, deprecated, message: "Use Synchronization.Mutex included with Swift 6")
33+
34+ // @available(macOS, deprecated: 15.0, message: "use Mutex from Synchronization module included with Swift 6")
35+ // @available(iOS, deprecated: 18.0, message: "use Mutex from Synchronization module included with Swift 6")
36+ // @available(tvOS, deprecated: 18.0, message: "use Mutex from Synchronization module included with Swift 6")
37+ // @available(watchOS, deprecated: 11.0, message: "use Mutex from Synchronization module included with Swift 6")
38+ // @available(visionOS, deprecated: 2.0, message: "use Mutex from Synchronization module included with Swift 6")
3439public struct Mutex < Value> : @unchecked Sendable {
3540 let lock : AllocatedLock < Value > // Compatible with OSAllocatedUnfairLock iOS 16+
3641}
@@ -73,6 +78,13 @@ public extension Mutex {
7378 }
7479 }
7580}
81+ private struct Transferring < T> {
82+ nonisolated ( unsafe) var value: T
83+
84+ init ( _ value: T ) {
85+ self . value = value
86+ }
87+ }
7688#else
7789public extension Mutex {
7890 init ( _ initialValue: consuming Value ) {
@@ -96,14 +108,3 @@ public extension Mutex {
96108 }
97109}
98110#endif
99-
100-
101- #if compiler(>=6)
102- struct Transferring < T> {
103- nonisolated ( unsafe) var value: T
104-
105- init ( _ value: T ) {
106- self . value = value
107- }
108- }
109- #endif
Original file line number Diff line number Diff line change @@ -49,18 +49,18 @@ final class MutexTests: XCTestCase {
4949 }
5050 }
5151
52- func testLockIfAvailable_ReturnsValue( ) {
53- let mutex = Mutex ( " fish " )
54- mutex. lock. unsafeLock ( )
55- XCTAssertNil (
56- mutex. withLockIfAvailable { _ in " chips " }
57- )
58- mutex. lock. unsafeUnlock ( )
59- XCTAssertEqual (
60- mutex. withLockIfAvailable { _ in " chips " } ,
61- " chips "
62- )
63- }
52+ // func testLockIfAvailable_ReturnsValue() {
53+ // let mutex = Mutex("fish")
54+ // mutex.lock.unsafeLock()
55+ // XCTAssertNil(
56+ // mutex.withLockIfAvailable { _ in "chips" }
57+ // )
58+ // mutex.lock.unsafeUnlock()
59+ // XCTAssertEqual(
60+ // mutex.withLockIfAvailable { _ in "chips" },
61+ // "chips"
62+ // )
63+ // }
6464
6565 func testWithLockIfAvailable_ThrowsError( ) {
6666 let mutex = Mutex ( " fish " )
Original file line number Diff line number Diff line change 44
55docker run -it \
66 --rm \
7- --mount src=" $( pwd) " ,target=/allocatedlock ,type=bind \
7+ --mount src=" $( pwd) " ,target=/mutex ,type=bind \
88 swiftlang/swift:nightly-6.0-jammy \
9- /usr/bin/swift test --package-path /allocatedlock
9+ /usr/bin/swift test --package-path /mutex
You can’t perform that action at this time.
0 commit comments