 class DefaultDatafileHandler : OPTDatafileHandler {
     static public var endPointStringFormat = "https://cdn.optimizely.com/datafiles/%@.json"
     lazy var logger = HandlerRegistryService.shared.injectLogger()
-    var timers:[String:Timer] = [String:Timer]()
+    var timers:AtomicProperty<[String:Timer]> = AtomicProperty(property: [String:Timer]())
     let dataStore = DataStoreUserDefaults()
     
     required init() {

    
    func downloadDatafile(sdkKey: String) -> Data? {
        
        let config = URLSessionConfiguration.ephemeral
        let session = URLSession(configuration: config)
        let str = String(format: DefaultDatafileHandler.endPointStringFormat, sdkKey)
        var result:Data?
        let group = DispatchGroup()
        
        group.enter()
        
        if let url = URL(string: str) {
            let task = session.downloadTask(with: url){ (url, response, error) in
                self.logger?.log(level: .debug, message: response.debugDescription)
                if let response = response as? HTTPURLResponse, response.statusCode == 200,
                    let url = url, let projectConfig = try? Data(contentsOf: url) {
                    result = projectConfig
                    self.saveDatafile(sdkKey: sdkKey, dataFile: projectConfig)
                }
                group.leave()
            }
            
            task.resume()
            
            group.wait()
            
        }
        return result
    }
    
    open func downloadDatafile(sdkKey: String, completionHandler: @escaping (Result<Data?, DatafileDownloadError>) -> Void) {
        let config = URLSessionConfiguration.ephemeral
        let session = URLSession(configuration: config)
        let str = String(format: DefaultDatafileHandler.endPointStringFormat, sdkKey)

    }
    
    func stopPeriodicUpdates(sdkKey: String) {
        timers.performAtomic { (timers) in
            if let timer = timers[sdkKey] {
                logger?.log(level: .info, message: "Stopping timer for datafile updates sdkKey: \(sdkKey)")
                
                timer.invalidate()
                timers.removeValue(forKey: sdkKey)
            }

        }
    }
    
    func stopPeriodicUpdates() {
        timers.performAtomic { (timers) in
            for key in timers.keys {
                logger?.log(level: .info, message: "Stopping timer for all datafile updates")
                stopPeriodicUpdates(sdkKey: key)
            }
        }
        
    }
