All Downloads are FREE. Search and download functionalities are using the official Maven repository.

swift5.SynchronizedDictionary.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
// SynchronizedDictionary.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation

internal struct SynchronizedDictionary {

    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
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy