Skip to content

Commit 1cacaf6

Browse files
committed
Foundation: rename some internal variables (NFC)
Remove the POSIX-iness of the typenames to make the Windows port feel more natural.
1 parent b23dc8e commit 1cacaf6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Foundation/NSLock.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ public protocol NSLocking {
2222
}
2323

2424
#if CYGWIN
25-
private typealias _PthreadMutexPointer = UnsafeMutablePointer<pthread_mutex_t?>
26-
private typealias _PthreadCondPointer = UnsafeMutablePointer<pthread_cond_t?>
25+
private typealias _MutexPointer = UnsafeMutablePointer<pthread_mutex_t?>
26+
private typealias _ConditionVariablePointer = UnsafeMutablePointer<pthread_cond_t?>
2727
#else
28-
private typealias _PthreadMutexPointer = UnsafeMutablePointer<pthread_mutex_t>
29-
private typealias _PthreadCondPointer = UnsafeMutablePointer<pthread_cond_t>
28+
private typealias _MutexPointer = UnsafeMutablePointer<pthread_mutex_t>
29+
private typealias _ConditionVariablePointer = UnsafeMutablePointer<pthread_cond_t>
3030
#endif
3131

3232
open class NSLock: NSObject, NSLocking {
33-
internal var mutex = _PthreadMutexPointer.allocate(capacity: 1)
33+
internal var mutex = _MutexPointer.allocate(capacity: 1)
3434
#if os(macOS) || os(iOS)
35-
private var timeoutCond = _PthreadCondPointer.allocate(capacity: 1)
36-
private var timeoutMutex = _PthreadMutexPointer.allocate(capacity: 1)
35+
private var timeoutCond = _ConditionVariablePointer.allocate(capacity: 1)
36+
private var timeoutMutex = _MutexPointer.allocate(capacity: 1)
3737
#endif
3838

3939
public override init() {
@@ -175,10 +175,10 @@ open class NSConditionLock : NSObject, NSLocking {
175175
}
176176

177177
open class NSRecursiveLock: NSObject, NSLocking {
178-
internal var mutex = _PthreadMutexPointer.allocate(capacity: 1)
178+
internal var mutex = _MutexPointer.allocate(capacity: 1)
179179
#if os(macOS) || os(iOS)
180-
private var timeoutCond = _PthreadCondPointer.allocate(capacity: 1)
181-
private var timeoutMutex = _PthreadMutexPointer.allocate(capacity: 1)
180+
private var timeoutCond = _ConditionVariablePointer.allocate(capacity: 1)
181+
private var timeoutMutex = _MutexPointer.allocate(capacity: 1)
182182
#endif
183183

184184
public override init() {
@@ -240,8 +240,8 @@ open class NSRecursiveLock: NSObject, NSLocking {
240240
}
241241

242242
open class NSCondition: NSObject, NSLocking {
243-
internal var mutex = _PthreadMutexPointer.allocate(capacity: 1)
244-
internal var cond = _PthreadCondPointer.allocate(capacity: 1)
243+
internal var mutex = _MutexPointer.allocate(capacity: 1)
244+
internal var cond = _ConditionVariablePointer.allocate(capacity: 1)
245245

246246
public override init() {
247247
pthread_mutex_init(mutex, nil)
@@ -301,7 +301,7 @@ private func timeSpecFrom(date: Date) -> timespec? {
301301

302302
#if os(macOS) || os(iOS)
303303

304-
private func deallocateTimedLockData(cond: _PthreadCondPointer, mutex: _PthreadMutexPointer) {
304+
private func deallocateTimedLockData(cond: _ConditionVariablePointer, mutex: _MutexPointer) {
305305
pthread_cond_destroy(cond)
306306
cond.deinitialize(count: 1)
307307
cond.deallocate()
@@ -314,9 +314,9 @@ private func deallocateTimedLockData(cond: _PthreadCondPointer, mutex: _PthreadM
314314
// Emulate pthread_mutex_timedlock using pthread_cond_timedwait.
315315
// lock(before:) passes a condition variable/mutex pair to use.
316316
// unlock() will use pthread_cond_broadcast() to wake any waits in progress.
317-
private func timedLock(mutex: _PthreadMutexPointer, endTime: Date,
318-
using timeoutCond: _PthreadCondPointer,
319-
with timeoutMutex: _PthreadMutexPointer) -> Bool {
317+
private func timedLock(mutex: _MutexPointer, endTime: Date,
318+
using timeoutCond: _ConditionVariablePointer,
319+
with timeoutMutex: _MutexPointer) -> Bool {
320320

321321
var timeSpec = timeSpecFrom(date: endTime)
322322
while var ts = timeSpec {

0 commit comments

Comments
 (0)