 		precondition(!downloadingAllFiles)
 		assert(tasks.count == 0)
 		return SignalProducer<Double, FileCacheError>() { observer, disposable in
-			self.taskLock.lock()
-			defer { self.taskLock.unlock() }
-			assert(self.tasks.count == 0)
-			if self.workspace.files.count < 1 {
-				observer.sendCompleted()
-				return
-			}
-			self.totalDownloadSize = self.workspace.files.reduce(0) { $0 + $1.fileSize }
-			for aFile in self.workspace.files {
-				let theTask = DownloadTask(file: aFile, cache: self)
-				self.tasks[theTask.task.taskIdentifier] = theTask
-			}
-			//prepare signal for success notification
-			let (signal, sobserver) = Signal<Bool, NoError>.pipe()
-			self.downloadInProgressSignal = signal
-			self.downloadInProgressObserver = sobserver
-			//only start after all tasks are created
-			DispatchQueue.main.async {
-				self.taskLock.lock()
-				defer { self.taskLock.unlock() }
-				self.tasks.forEach { $0.value.task.resume() }
-			}
-			self.downloadingAllFiles = true
+			self.taskLockQueue.sync {
+				assert(self.tasks.count == 0)
+				if self.workspace.files.count < 1 {
+					observer.sendCompleted()
+					return
+				}
+				self.totalDownloadSize = self.workspace.files.reduce(0) { $0 + $1.fileSize }
+				for aFile in self.workspace.files {
+					let theTask = DownloadTask(file: aFile, cache: self)
+					self.tasks[theTask.task.taskIdentifier] = theTask
+				}
+				//prepare signal for success notification
+				let (signal, sobserver) = Signal<Bool, NoError>.pipe()
+				self.downloadInProgressSignal = signal
+				self.downloadInProgressObserver = sobserver
+				//only start after all tasks are created
+				DispatchQueue.main.async {
+					self.taskLockQueue.sync {
+						self.tasks.forEach { $0.value.task.resume() }
+					}
+				}
+				self.downloadingAllFiles = true
+			}
 		}
 	}
 	

		task = cache.urlSession!.downloadTask(with: request)
	}
}


		urlSession?.invalidateAndCancel()
	}
	
	public func isFileCached(_ file:File) -> Bool {
		return cachedUrl(file:file).fileExists()
	}

	@discardableResult public func flushCache(workspace:Workspace) {
		
	}
	
