@@ -238,7 +238,7 @@ public struct LocalTestingDistributedActorSystemError: DistributedActorSystemErr
238
238
@available ( SwiftStdlib 5 . 7 , * )
239
239
@safe
240
240
fileprivate class _Lock {
241
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
241
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
242
242
private let underlying : UnsafeMutablePointer < os_unfair_lock >
243
243
#elseif os(Windows)
244
244
private let underlying : UnsafeMutablePointer < SRWLOCK >
@@ -251,7 +251,7 @@ fileprivate class _Lock {
251
251
#endif
252
252
253
253
init ( ) {
254
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
254
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
255
255
self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
256
256
unsafe self. underlying . initialize ( to: os_unfair_lock ( ) )
257
257
#elseif os(Windows)
@@ -261,21 +261,21 @@ fileprivate class _Lock {
261
261
// WASI environment has only a single thread
262
262
#else
263
263
self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
264
- guard pthread_mutex_init ( self . underlying, nil ) == 0 else {
264
+ guard unsafe pthread_mutex_init( self . underlying, nil ) == 0 else {
265
265
fatalError ( " pthread_mutex_init failed " )
266
266
}
267
267
#endif
268
268
}
269
269
270
270
deinit {
271
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
271
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
272
272
// `os_unfair_lock`s do not need to be explicitly destroyed
273
273
#elseif os(Windows)
274
274
// `SRWLOCK`s do not need to be explicitly destroyed
275
275
#elseif os(WASI)
276
276
// WASI environment has only a single thread
277
277
#else
278
- guard pthread_mutex_destroy ( self . underlying) == 0 else {
278
+ guard unsafe pthread_mutex_destroy( self . underlying) == 0 else {
279
279
fatalError ( " pthread_mutex_destroy failed " )
280
280
}
281
281
#endif
@@ -289,27 +289,27 @@ fileprivate class _Lock {
289
289
290
290
@discardableResult
291
291
func withLock< T> ( _ body: ( ) -> T ) -> T {
292
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
292
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
293
293
unsafe os_unfair_lock_lock( self . underlying)
294
294
#elseif os(Windows)
295
295
AcquireSRWLockExclusive ( self . underlying)
296
296
#elseif os(WASI)
297
297
// WASI environment has only a single thread
298
298
#else
299
- guard pthread_mutex_lock ( self . underlying) == 0 else {
299
+ guard unsafe pthread_mutex_lock( self . underlying) == 0 else {
300
300
fatalError ( " pthread_mutex_lock failed " )
301
301
}
302
302
#endif
303
303
304
304
defer {
305
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
305
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(visionOS)
306
306
unsafe os_unfair_lock_unlock( self . underlying)
307
307
#elseif os(Windows)
308
308
ReleaseSRWLockExclusive ( self . underlying)
309
309
#elseif os(WASI)
310
310
// WASI environment has only a single thread
311
311
#else
312
- guard pthread_mutex_unlock ( self . underlying) == 0 else {
312
+ guard unsafe pthread_mutex_unlock( self . underlying) == 0 else {
313
313
fatalError ( " pthread_mutex_unlock failed " )
314
314
}
315
315
#endif
0 commit comments