Skip to content

Commit f696b71

Browse files
committed
fix sessions build
1 parent 7a40e87 commit f696b71

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

FirebaseSessions/Sources/Settings/RemoteSettings.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class RemoteSettings: SettingsProvider, Sendable {
3131
private static let flagSessionsCache = "app_quality"
3232
private let appInfo: ApplicationInfoProtocol
3333
private let downloader: SettingsDownloadClient
34-
private let cache: AtomicBox<SettingsCacheClient>
34+
private let cache: FIRAllocatedUnfairLock<SettingsCacheClient>
3535

3636
private var cacheDurationSeconds: TimeInterval {
3737
cache.withLock { cache in
@@ -52,7 +52,7 @@ final class RemoteSettings: SettingsProvider, Sendable {
5252
downloader: SettingsDownloadClient,
5353
cache: SettingsCacheClient = SettingsCache()) {
5454
self.appInfo = appInfo
55-
self.cache = AtomicBox<SettingsCacheClient>(cache)
55+
self.cache = FIRAllocatedUnfairLock(initialState: cache)
5656
self.downloader = downloader
5757
}
5858

FirebaseSessions/Sources/Settings/SettingsCacheClient.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
import Foundation
1717

18+
// TODO: sendable (remove preconcurrency)
1819
#if SWIFT_PACKAGE
19-
@_implementationOnly import GoogleUtilities_UserDefaults
20+
@_implementationOnly @preconcurrency import GoogleUtilities_UserDefaults
2021
#else
21-
@_implementationOnly import GoogleUtilities
22+
@_implementationOnly @preconcurrency import GoogleUtilities
2223
#endif // SWIFT_PACKAGE
2324

2425
/// CacheKey is like a "key" to a "safe". It provides necessary metadata about the current cache to
@@ -30,7 +31,7 @@ struct CacheKey: Codable {
3031
}
3132

3233
/// SettingsCacheClient is responsible for accessing the cache that Settings are stored in.
33-
protocol SettingsCacheClient {
34+
protocol SettingsCacheClient: Sendable {
3435
/// Returns in-memory cache content in O(1) time. Returns empty dictionary if it does not exist in
3536
/// cache.
3637
var cacheContent: [String: Any] { get set }
@@ -45,7 +46,7 @@ protocol SettingsCacheClient {
4546
/// when accessing Settings values during run-time. This is because UserDefaults encapsulates both
4647
/// in-memory and persisted-on-disk storage, allowing fast synchronous access in-app while hiding
4748
/// away the complexity of managing persistence asynchronously.
48-
class SettingsCache: SettingsCacheClient {
49+
final class SettingsCache: SettingsCacheClient {
4950
private static let settingsVersion: Int = 1
5051
private enum UserDefaultsKeys {
5152
static let forContent = "firebase-sessions-settings"

0 commit comments

Comments
 (0)