Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit f7f830c

Browse files
committed
Updated Lock API
1 parent 25e73f4 commit f7f830c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Sources/SwiftFoundation/Lock.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public protocol Locking {
1818
func unlock()
1919
}
2020

21-
public class Lock: Locking {
21+
public final class Lock: Locking {
2222

2323
private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
2424

@@ -48,17 +48,17 @@ public class Lock: Locking {
4848
}
4949

5050
extension Lock {
51-
internal func synchronized<T>(_ closure: @noescape () -> T) -> T {
51+
private func synchronized<T>(_ closure: @noescape () -> T) -> T {
5252
self.lock()
5353
defer { self.unlock() }
5454
return closure()
5555
}
5656
}
5757

58-
public class NSConditionLock : NSObject, Locking {
59-
internal var _cond = Condition()
60-
internal var _value: Int
61-
internal var _thread: pthread_t?
58+
public final class ConditionLock : NSObject, Locking {
59+
private var _cond = Condition()
60+
private var _value: Int
61+
private var _thread: pthread_t?
6262

6363
public convenience override init() {
6464
self.init(condition: 0)
@@ -132,11 +132,11 @@ public class NSConditionLock : NSObject, Locking {
132132
public var name: String?
133133
}
134134

135-
public class RecursiveLock: NSObject, Locking {
136-
internal var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
135+
public final class RecursiveLock: Locking {
136+
private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
137137

138-
public override init() {
139-
super.init()
138+
public init() {
139+
140140
var attrib = pthread_mutexattr_t()
141141
withUnsafeMutablePointer(&attrib) { attrs in
142142
pthread_mutexattr_settype(attrs, Int32(PTHREAD_MUTEX_RECURSIVE))
@@ -165,11 +165,11 @@ public class RecursiveLock: NSObject, Locking {
165165
public var name: String?
166166
}
167167

168-
public class Condition: NSObject, Locking {
169-
internal var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
170-
internal var cond = UnsafeMutablePointer<pthread_cond_t>(allocatingCapacity: 1)
168+
public final class Condition: Locking {
169+
private var mutex = UnsafeMutablePointer<pthread_mutex_t>(allocatingCapacity: 1)
170+
private var cond = UnsafeMutablePointer<pthread_cond_t>(allocatingCapacity: 1)
171171

172-
public override init() {
172+
public init() {
173173
pthread_mutex_init(mutex, nil)
174174
pthread_cond_init(cond, nil)
175175
}

0 commit comments

Comments
 (0)