Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,18 @@ public func _stdlib_thread_join<Result>(
) -> (CInt, Result?) {
#if os(Windows)
let result = WaitForSingleObject(thread, INFINITE)
if result == WAIT_OBJECT_0 {
var threadResult: DWORD = 0
GetExitCodeThread(thread, &threadResult)
CloseHandle(thread)

return (CInt(result),
UnsafeMutablePointer<DWORD>(&threadResult)
.withMemoryRebound(to: Result.self, capacity: 1){ $0.pointee })
} else {
return (CInt(result), nil)
guard result == WAIT_OBJECT_0 else { return (CInt(result), nil) }

var dwResult: DWORD = 0
GetExitCodeThread(thread, &dwResult)
CloseHandle(thread)

let value: Result = withUnsafePointer(to: &dwResult) {
$0.withMemoryRebound(to: Result.self, capacity: 1) {
$0.pointee
}
}
return (CInt(result), value)
#else
var threadResultRawPtr: UnsafeMutableRawPointer?
let result = pthread_join(thread, &threadResultRawPtr)
Expand Down