File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -117,17 +117,18 @@ public func _stdlib_thread_join<Result>(
117
117
) -> ( CInt , Result ? ) {
118
118
#if os(Windows)
119
119
let result = WaitForSingleObject ( thread, INFINITE)
120
- if result == WAIT_OBJECT_0 {
121
- var threadResult : DWORD = 0
122
- GetExitCodeThread ( thread , & threadResult )
123
- CloseHandle ( thread)
124
-
125
- return ( CInt ( result ) ,
126
- UnsafeMutablePointer < DWORD > ( & threadResult )
127
- . withMemoryRebound ( to: Result . self, capacity: 1 ) { $0 . pointee } )
128
- } else {
129
- return ( CInt ( result ) , nil )
120
+ guard result == WAIT_OBJECT_0 else { return ( CInt ( result ) , nil ) }
121
+
122
+ var dwResult : DWORD = 0
123
+ GetExitCodeThread ( thread, & dwResult )
124
+ CloseHandle ( thread )
125
+
126
+ let value : Result = withUnsafePointer ( to : & dwResult ) {
127
+ $0 . withMemoryRebound ( to: Result . self, capacity: 1 ) {
128
+ $0 . pointee
129
+ }
130
130
}
131
+ return ( CInt ( result) , value)
131
132
#else
132
133
var threadResultRawPtr : UnsafeMutableRawPointer ?
133
134
let result = pthread_join ( thread, & threadResultRawPtr)
You can’t perform that action at this time.
0 commit comments