Skip to content

Commit

Permalink
Improve thread safety during annotation clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
vospennikov committed Oct 3, 2023
1 parent 03332e4 commit e5de4f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/ClusterMap/Public/Core/ClusterManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private extension ClusterManager {
}

func applyVisibleAnnotationChanges(toAdd: [AnnotationType], toRemove: [AnnotationType]) {
dispatchQueue.async(flags: .barrier) { [weak self] in
dispatchQueue.sync(flags: .barrier) { [weak self] in
self?.visibleAnnotations.subtract(toRemove)
self?.visibleAnnotations.add(toAdd)
}
Expand Down Expand Up @@ -280,7 +280,7 @@ private extension ClusterManager {
tree.findAnnotations(in: mapRect)
}
let hash = Dictionary(grouping: annotations) { $0.coordinate }
dispatchQueue.async(flags: .barrier) {
dispatchQueue.sync(flags: .barrier) {
for value in hash.values where value.count > 1 {
let radiansBetweenAnnotations = (.pi * 2) / Double(value.count)
for (index, annotation) in value.enumerated() {
Expand Down

0 comments on commit e5de4f6

Please sign in to comment.