forked from loafle/openapi-generator-original
* [swift5] Add useSPMFileStructure Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com> * [swift5] Add swiftPackagePath Prioritize swiftPackagePath over useSPMFileStructure * [swift5] Add cli options and update docs * [swift5] Fix tests * [swift5] Update XcodeGen source path * [swift5] Update samples and docs Add useSPMFileStructure to URLSession library
37 lines
859 B
Swift
37 lines
859 B
Swift
// SynchronizedDictionary.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
|
|
internal struct SynchronizedDictionary<K: Hashable, V> {
|
|
|
|
private var dictionary = [K: V]()
|
|
private let queue = DispatchQueue(
|
|
label: "SynchronizedDictionary",
|
|
qos: DispatchQoS.userInitiated,
|
|
attributes: [DispatchQueue.Attributes.concurrent],
|
|
autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit,
|
|
target: nil
|
|
)
|
|
|
|
internal subscript(key: K) -> V? {
|
|
get {
|
|
var value: V?
|
|
|
|
queue.sync {
|
|
value = self.dictionary[key]
|
|
}
|
|
|
|
return value
|
|
}
|
|
set {
|
|
queue.sync(flags: DispatchWorkItemFlags.barrier) {
|
|
self.dictionary[key] = newValue
|
|
}
|
|
}
|
|
}
|
|
}
|