Skip to content

Commit

Permalink
RUM-3574 Start sending batches immediately after feature is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
ncreated committed Apr 25, 2024
1 parent 79943d3 commit 25e7c0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions DatadogCore/Sources/Core/Upload/DataUploadDelay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class DataUploadDelay {
private let maxDelay: TimeInterval
private let changeRate: Double

@ReadWriteLock
private(set) var current: TimeInterval

init(performance: UploadPerformancePreset) {
Expand Down
8 changes: 5 additions & 3 deletions DatadogCore/Sources/Core/Upload/DataUploadWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ internal class DataUploadWorker: DataUploadWorkerType {
self.maxBatchesPerUpload = maxBatchesPerUpload
self.featureName = featureName
self.telemetry = telemetry

self.readWork = DispatchWorkItem { [weak self] in
let readWorkItem = DispatchWorkItem { [weak self] in
guard let self = self else {
return
}
Expand All @@ -87,7 +86,10 @@ internal class DataUploadWorker: DataUploadWorkerType {
self.scheduleNextCycle()
}
}
scheduleNextCycle()
self.readWork = readWorkItem

// Start sending batches immediately after initialization:
queue.async(execute: readWorkItem)
}

private func scheduleNextCycle() {
Expand Down

0 comments on commit 25e7c0c

Please sign in to comment.