Skip to content

Commit

Permalink
Using a background queue for session upload in SessionController
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoEmbrace committed Jul 23, 2024
1 parent dd8afa2 commit 899ae2c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/EmbraceCore/Session/SessionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -161,7 +163,9 @@ class SessionController: SessionControllable {
return
}

UnsentDataHandler.sendSession(session, storage: storage, upload: upload)
queue.async {
UnsentDataHandler.sendSession(session, storage: storage, upload: upload)
}
}
}

Expand Down

0 comments on commit 899ae2c

Please sign in to comment.