Skip to content

Commit bb42155

Browse files
damuellenphausler
authored andcommitted
[NSThread] Updated to match Darwin version (swiftlang#440)
* Updated to match Darwin version * Fixed other occurence of Thread.current
1 parent 0d9628a commit bb42155

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Foundation/NSThread.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private func NSThreadStart(_ context: UnsafeMutablePointer<Void>?) -> UnsafeMuta
5959
public class Thread: NSObject {
6060

6161
static internal var _currentThread = NSThreadSpecific<Thread>()
62-
public static func current() -> Thread {
62+
public static var current: Thread {
6363
return Thread._currentThread.get() {
6464
return Thread(thread: pthread_self())
6565
}

Foundation/NSXMLParser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public class XMLParser : NSObject {
460460
public var allowedExternalEntityURLs: Set<URL>?
461461

462462
internal static func currentParser() -> XMLParser? {
463-
if let current = Thread.current().threadDictionary["__CurrentNSXMLParser"] {
463+
if let current = Thread.current.threadDictionary["__CurrentNSXMLParser"] {
464464
return current as? XMLParser
465465
} else {
466466
return nil
@@ -469,9 +469,9 @@ public class XMLParser : NSObject {
469469

470470
internal static func setCurrentParser(_ parser: XMLParser?) {
471471
if let p = parser {
472-
Thread.current().threadDictionary["__CurrentNSXMLParser"] = p
472+
Thread.current.threadDictionary["__CurrentNSXMLParser"] = p
473473
} else {
474-
Thread.current().threadDictionary.removeValue(forKey: "__CurrentNSXMLParser")
474+
Thread.current.threadDictionary.removeValue(forKey: "__CurrentNSXMLParser")
475475
}
476476
}
477477

TestFoundation/TestNSThread.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class TestNSThread : XCTestCase {
2626
}
2727

2828
func test_currentThread() {
29-
let thread1 = Thread.current()
30-
let thread2 = Thread.current()
29+
let thread1 = Thread.current
30+
let thread2 = Thread.current
3131
XCTAssertNotNil(thread1)
3232
XCTAssertNotNil(thread2)
3333
XCTAssertEqual(thread1, thread2)

0 commit comments

Comments
 (0)