Wait to write metrics

This commit is contained in:
Christoph Hagen 2023-09-07 16:00:02 +02:00
parent 253017c429
commit 44b776ef32

View File

@ -118,10 +118,13 @@ private func migrateMetric<T>(_ id: String, containing type: T.Type, in folder:
// TODO: Write values back to disk // TODO: Write values back to disk
let observer = MetricObserver(logFileFolder: folder, logMetricId: "sesame.migration") let observer = MetricObserver(logFileFolder: folder, logMetricId: "sesame.migration")
let metric: Metric<T> = observer.addMetric(id: id) let metric: Metric<T> = observer.addMetric(id: id)
private let semaphore = DispatchSemaphore(value: 0)
Task { Task {
try await metric.update(all) try await metric.update(all)
print("Saved all values for metric \(id)") print("Saved all values for metric \(id)")
semaphore.signal()
} }
semaphore.wait()
print("Finished metric \(id)") print("Finished metric \(id)")
} }