Commit 86d8f192 authored by Daniel Tull's avatar Daniel Tull

Replace use of pthread mutex with NSLock

parent 91f56193
......@@ -62,15 +62,15 @@ extension CombineLatestCollection {
var values: [Publishers.Element.Output?] = Array(repeating: nil, count: publishers.count)
var completions = 0
var hasCompleted = false
var lock = pthread_mutex_t()
let lock = NSLock()
subscribers = publishers.enumerated().map { index, publisher in
publisher
.sink(receiveCompletion: { completion in
pthread_mutex_lock(&lock)
defer { pthread_mutex_unlock(&lock) }
lock.lock()
defer { lock.unlock() }
guard case .finished = completion else {
// One failure in any of the publishers cause a
......@@ -89,8 +89,8 @@ extension CombineLatestCollection {
}, receiveValue: { value in
pthread_mutex_lock(&lock)
defer { pthread_mutex_unlock(&lock) }
lock.lock()
defer { lock.unlock() }
guard !hasCompleted else { return }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment