File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,12 @@ public extension AllocatedLock where State == Void {
5858 self . storage = Storage ( initialState: ( ) )
5959 }
6060
61- @inlinable
61+ @inlinable @ available ( * , noasync )
6262 func lock( ) {
6363 storage. lock ( )
6464 }
6565
66- @inlinable
66+ @inlinable @ available ( * , noasync )
6767 func unlock( ) {
6868 storage. unlock ( )
6969 }
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ final class AllocatedLockTests: XCTestCase {
5959 @MainActor
6060 func testLock_Blocks( ) async {
6161 let lock = AllocatedLock ( )
62- lock. lock ( )
62+ lock. unsafeLock ( )
6363
6464 Task {
6565 try ? await Task . sleep ( nanoseconds: 1_000_000_000 )
66- lock. unlock ( )
66+ lock. unsafeUnlock ( )
6767 }
6868
6969 let results = await withTaskGroup ( of: Bool . self) { group in
@@ -72,8 +72,8 @@ final class AllocatedLockTests: XCTestCase {
7272 return true
7373 }
7474 group. addTask {
75- lock. lock ( )
76- lock. unlock ( )
75+ lock. unsafeLock ( )
76+ lock. unsafeUnlock ( )
7777 return false
7878 }
7979 let first = await group. next ( ) !
@@ -83,3 +83,9 @@ final class AllocatedLockTests: XCTestCase {
8383 XCTAssertEqual ( results, [ true , false ] )
8484 }
8585}
86+
87+ // sidestep warning: unavailable from asynchronous contexts
88+ extension AllocatedLock where State == Void {
89+ func unsafeLock( ) { lock ( ) }
90+ func unsafeUnlock( ) { unlock ( ) }
91+ }
You can’t perform that action at this time.
0 commit comments