Skip to content

Commit

Permalink
Replace 'nonisolated(unsafe)' from Swift 5.10+ with a more compatible…
Browse files Browse the repository at this point in the history
… approach
  • Loading branch information
Jeehut committed Nov 26, 2024
1 parent 1d9ac49 commit be695c4
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 be695c4

Please sign in to comment.