Skip to content

Commit 0edaa77

Browse files
committed
[gardening] Use a didSet observer for Thread.name
1 parent 1665716 commit 0edaa77

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Foundation/NSThread.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ open class Thread : NSObject {
143143
#endif
144144
internal var _status = _NSThreadStatus.initialized
145145
internal var _cancelled = false
146-
internal var _name: String?
147146
/// - Note: this differs from the Darwin implementation in that the keys must be Strings
148147
open var threadDictionary = [String : Any]()
149148

@@ -192,14 +191,9 @@ open class Thread : NSObject {
192191
}
193192

194193
open var name: String? {
195-
get {
196-
return _name
197-
}
198-
set {
199-
_name = newValue
200-
194+
didSet {
201195
if _thread == Thread.current._thread {
202-
_CFThreadSetName(_name)
196+
_CFThreadSetName(name)
203197
}
204198
}
205199
}

0 commit comments

Comments
 (0)