File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -251,9 +251,12 @@ open class Thread : NSObject {
251
251
}
252
252
253
253
open var name : String ? {
254
- didSet {
254
+ get {
255
+ return _name
256
+ }
257
+ set {
255
258
if let thread = _thread {
256
- _CFThreadSetName ( thread, name ?? " " )
259
+ _CFThreadSetName ( thread, newValue ?? " " )
257
260
}
258
261
}
259
262
}
Original file line number Diff line number Diff line change @@ -68,16 +68,17 @@ class TestThread : XCTestCase {
68
68
69
69
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
70
70
func test_threadName( ) {
71
- // No name is set initially
72
- XCTAssertNil ( Thread . current. name)
73
-
74
71
#if os(Linux) // Linux sets the initial thread name to the process name.
72
+ XCTAssertEqual ( Thread . current. name, " TestFoundation " )
75
73
XCTAssertEqual ( Thread . current. _name, " TestFoundation " )
76
74
#else
75
+ // No name is set initially
76
+ XCTAssertEqual ( Thread . current. name, " " )
77
77
XCTAssertEqual ( Thread . current. _name, " " )
78
78
#endif
79
79
Thread . current. name = " mainThread "
80
80
XCTAssertEqual ( Thread . mainThread. name, " mainThread " )
81
+ XCTAssertEqual ( Thread . mainThread. _name, " mainThread " )
81
82
82
83
let condition = NSCondition ( )
83
84
condition. lock ( )
You can’t perform that action at this time.
0 commit comments