Fixed an issue where XCode 15 would hang on launch due to being unable to retrieve a read lock

This commit is contained in:
Morgan Pretty 2023-09-21 13:43:11 +10:00
parent 4c934d2fda
commit cdf918194a
1 changed files with 7 additions and 4 deletions

View File

@ -81,11 +81,14 @@ extension Atomic where Value: CustomDebugStringConvertible {
// MARK: - ReadWriteLock
private class ReadWriteLock {
private var rwlock: pthread_rwlock_t = {
var rwlock = pthread_rwlock_t()
private var rwlock: pthread_rwlock_t
// Need to do this in a proper init function instead of a lazy variable or it can indefinitely
// hang on XCode 15 when trying to retrieve a lock (potentially due to optimisations?)
init() {
rwlock = pthread_rwlock_t()
pthread_rwlock_init(&rwlock, nil)
return rwlock
}()
}
func writeLock() {
pthread_rwlock_wrlock(&rwlock)