detach threads so we don't leak them

This commit is contained in:
Johannes Weiß 2018-02-08 10:57:51 +00:00
parent 453b87ff5e
commit b26bfce61e
1 changed files with 5 additions and 4 deletions

View File

@ -90,11 +90,12 @@ final class Thread {
fn(Thread(pthread: pt))
return nil
}, Unmanaged.passRetained(box).toOpaque());
}, Unmanaged.passRetained(box).toOpaque())
guard res == 0 else {
fatalError("Unable to create thread: \(res)")
}
precondition(res == 0, "Unable to create thread: \(res)")
let detachError = pthread_detach((pt as pthread_t?)!)
precondition(detachError == 0, "pthread_detach failed with error \(detachError)")
}
/// Returns `true` if the calling thread is the same as this one.