File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Sources/Swift/Core/Helper Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import Foundation
12
12
13
13
let newPackage = [ " name " : name, " version " : version]
14
14
15
+ // Thread-safe write using a barrier block on a concurrent queue.
16
+ // Ensures no other reads or writes happen during this insertion.
15
17
syncQueue. async ( flags: . barrier) {
16
18
extraPackages. insert ( newPackage)
17
19
}
@@ -20,6 +22,9 @@ import Foundation
20
22
@objc
21
23
public static func getPackages( ) -> NSMutableSet {
22
24
var copy : Set < [ String : String ] > = [ ]
25
+ // Thread-safe synchronous read on a concurrent queue.
26
+ // Multiple reads can happen concurrently unless a write barrier is active.
27
+ // Returns a copy to prevent external mutation of internal state.
23
28
syncQueue. sync {
24
29
copy = extraPackages
25
30
}
You can’t perform that action at this time.
0 commit comments