mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
27 lines
563 B
Swift
27 lines
563 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 lock = NSRecursiveLock()
|
|
|
|
internal subscript(key: K) -> V? {
|
|
get {
|
|
lock.lock()
|
|
defer { lock.unlock() }
|
|
return self.dictionary[key]
|
|
}
|
|
set {
|
|
lock.lock()
|
|
defer { lock.unlock() }
|
|
self.dictionary[key] = newValue
|
|
}
|
|
}
|
|
}
|