From 899ae2c5b1a3d7cc6b89a0336057e1478fcab27c Mon Sep 17 00:00:00 2001 From: Ignacio Tischelman Date: Tue, 23 Jul 2024 11:57:10 -0300 Subject: [PATCH] Using a background queue for session upload in SessionController --- Sources/EmbraceCore/Session/SessionController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/EmbraceCore/Session/SessionController.swift b/Sources/EmbraceCore/Session/SessionController.swift index 94e4677d..821b8359 100644 --- a/Sources/EmbraceCore/Session/SessionController.swift +++ b/Sources/EmbraceCore/Session/SessionController.swift @@ -35,6 +35,7 @@ class SessionController: SessionControllable { weak var storage: EmbraceStorage? weak var upload: EmbraceUpload? let heartbeat: SessionHeartbeat + let queue: DispatchQueue internal var notificationCenter = NotificationCenter.default @@ -48,6 +49,7 @@ class SessionController: SessionControllable { let heartbeatQueue = DispatchQueue(label: "com.embrace.session_heartbeat") self.heartbeat = SessionHeartbeat(queue: heartbeatQueue, interval: heartbeatInterval) + self.queue = DispatchQueue(label: "com.embrace.session_controller_upload") self.heartbeat.callback = { [weak self] in let heartbeat = Date() @@ -161,7 +163,9 @@ class SessionController: SessionControllable { return } - UnsentDataHandler.sendSession(session, storage: storage, upload: upload) + queue.async { + UnsentDataHandler.sendSession(session, storage: storage, upload: upload) + } } }