Skip to content

Commit

Permalink
Merge pull request #207 from TelemetryDeck/feature/swift-59-compatibi…
Browse files Browse the repository at this point in the history
…lity

Replace 'nonisolated(unsafe)' from Swift 5.10+ with a more compatible approach
  • Loading branch information
Jeehut authored Dec 2, 2024
2 parents 4c77613 + be695c4 commit 2be7acf
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Sources/TelemetryDeck/TelemetryClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,21 @@ public final class TelemetryManager: @unchecked Sendable {
self.startSessionAndObserveAppForegrounding()
}

nonisolated(unsafe)
static var initializedTelemetryManager: TelemetryManager?
private final class TelemetryManagerStorage: @unchecked Sendable {
static let shared = TelemetryManagerStorage()
private let queue = DispatchQueue(label: "com.telemetrydeck.TelemetryManager.static", attributes: .concurrent)
private var _manager: TelemetryManager?

var manager: TelemetryManager? {
get { queue.sync { _manager } }
set { queue.sync(flags: .barrier) { _manager = newValue } }
}
}

static var initializedTelemetryManager: TelemetryManager? {
get { TelemetryManagerStorage.shared.manager }
set { TelemetryManagerStorage.shared.manager = newValue }
}

let signalManager: SignalManageable

Expand Down

0 comments on commit 2be7acf

Please sign in to comment.