In my Swift
class I have multiple properties
. For these properties do I need to create different Concurrent Queue
or I can use the same Queue?
Please suggest which one will be better.
import Foundation
public class ImageCache{
public let shared = ImageCache()
private var imageFileNameDic = ["default": "default.png"]
private var notificationName = ["default.pn": "default-noti"]
//More properties will be here...
private let concurrentQueue = DispatchQueue(label: "conCurrentQueue", attributes: .concurrent)
public func setImageFileName(value: String, forKey key: String) {
concurrentQueue.async(flags: .barrier){
self.imageFileNameDic[key] = value
}
}
public func getImageFileName(forKey key: String) -> String? {
var result: String?
concurrentQueue.sync {
result = self.imageFileNameDic[key]
}
return result
}
//For notificationName dictionary do i need to declare another
//Queue or use the same Queue
public func setNotificationName(value: String, forKey key: String) {
//TODO::
}
public func getNotificationName(forKey key: String) {
//TODO::
}
}