File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,15 @@ final public class Thread {
65
65
}
66
66
}
67
67
}
68
+
69
+ /// Causes the calling thread to yield execution to another thread.
70
+ public static func yield( ) {
71
+ #if os(Windows)
72
+ SwitchToThread ( )
73
+ #else
74
+ sched_yield ( )
75
+ #endif
76
+ }
68
77
}
69
78
70
79
#if canImport(Darwin)
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ class LockTests: XCTestCase {
69
69
// Sum and write back to file.
70
70
try localFileSystem. writeFileContents ( fileA, bytes: ByteString ( encodingAsUTF8: String ( valueA + 1 ) ) )
71
71
72
- sched_yield ( )
72
+ Thread . yield ( )
73
73
74
74
// Get thr current contents of the file if any.
75
75
let valueB : Int
@@ -89,7 +89,7 @@ class LockTests: XCTestCase {
89
89
try ! lock. withLock ( type: . shared) {
90
90
try XCTAssertEqual ( localFileSystem. readFileContents ( fileA) , localFileSystem. readFileContents ( fileB) )
91
91
92
- sched_yield ( )
92
+ Thread . yield ( )
93
93
94
94
try XCTAssertEqual ( localFileSystem. readFileContents ( fileA) , localFileSystem. readFileContents ( fileB) )
95
95
}
You can’t perform that action at this time.
0 commit comments