Skip to content

add Sendable conformance to NSLock #4944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/Foundation/NSLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private typealias _RecursiveMutexPointer = UnsafeMutablePointer<pthread_mutex_t>
private typealias _ConditionVariablePointer = UnsafeMutablePointer<pthread_cond_t>
#endif

open class NSLock: NSObject, NSLocking {
open class NSLock: NSObject, NSLocking, @unchecked Sendable {
internal var mutex = _MutexPointer.allocate(capacity: 1)
#if os(macOS) || os(iOS) || os(Windows)
private var timeoutCond = _ConditionVariablePointer.allocate(capacity: 1)
Expand Down Expand Up @@ -165,7 +165,7 @@ extension NSLock {
}

#if SWIFT_CORELIBS_FOUNDATION_HAS_THREADS
open class NSConditionLock : NSObject, NSLocking {
open class NSConditionLock : NSObject, NSLocking, @unchecked Sendable {
internal var _cond = NSCondition()
internal var _value: Int
internal var _thread: _swift_CFThreadRef?
Expand Down Expand Up @@ -259,7 +259,7 @@ open class NSConditionLock : NSObject, NSLocking {
}
#endif

open class NSRecursiveLock: NSObject, NSLocking {
open class NSRecursiveLock: NSObject, NSLocking, @unchecked Sendable {
internal var mutex = _RecursiveMutexPointer.allocate(capacity: 1)
#if os(macOS) || os(iOS) || os(Windows)
private var timeoutCond = _ConditionVariablePointer.allocate(capacity: 1)
Expand Down Expand Up @@ -381,7 +381,7 @@ open class NSRecursiveLock: NSObject, NSLocking {
open var name: String?
}

open class NSCondition: NSObject, NSLocking {
open class NSCondition: NSObject, NSLocking, @unchecked Sendable {
internal var mutex = _MutexPointer.allocate(capacity: 1)
internal var cond = _ConditionVariablePointer.allocate(capacity: 1)

Expand Down