@@ -20,44 +20,83 @@ import Foundation
2020/// available at initialization.
2121///
2222/// - Tag: Amplify
23- public class Amplify {
23+ public class Amplify : @ unchecked Sendable {
2424
2525 /// If `true`, `configure()` has already been invoked, and subsequent calls to `configure` will throw a
2626 /// ConfigurationError.amplifyAlreadyConfigured error.
2727 ///
2828 /// - Tag: Amplify.isConfigured
29- static var isConfigured = false
29+ private static let isConfiguredAtomic = AtomicValue < Bool > ( initialValue: false )
30+ static var isConfigured : Bool {
31+ get { isConfiguredAtomic. get ( ) }
32+ set { isConfiguredAtomic. set ( newValue) }
33+ }
3034
3135 // Storage for the categories themselves, which will be instantiated during configuration, and cleared during reset.
32- // It is not supported to mutate these category properties. They are `var` to support the `reset()` method for
33- // ease of testing.
36+ // All category properties are protected with AtomicValue for thread safety.
3437
3538 /// - Tag: Amplify.Analytics
36- public static internal( set) var Analytics = AnalyticsCategory ( )
39+ private static let analyticsAtomic = AtomicValue < AnalyticsCategory > ( initialValue: AnalyticsCategory ( ) )
40+ public static internal( set) var Analytics : AnalyticsCategory {
41+ get { analyticsAtomic. get ( ) }
42+ set { analyticsAtomic. set ( newValue) }
43+ }
3744
3845 /// - Tag: Amplify.API
39- public static internal( set) var API : APICategory = APICategory ( )
46+ private static let apiAtomic = AtomicValue < APICategory > ( initialValue: APICategory ( ) )
47+ public static internal( set) var API : APICategory {
48+ get { apiAtomic. get ( ) }
49+ set { apiAtomic. set ( newValue) }
50+ }
4051
4152 /// - Tag: Amplify.Auth
42- public static internal( set) var Auth = AuthCategory ( )
53+ private static let authAtomic = AtomicValue < AuthCategory > ( initialValue: AuthCategory ( ) )
54+ public static internal( set) var Auth : AuthCategory {
55+ get { authAtomic. get ( ) }
56+ set { authAtomic. set ( newValue) }
57+ }
4358
4459 /// - Tag: Amplify.DataStore
45- public static internal( set) var DataStore = DataStoreCategory ( )
60+ private static let dataStoreAtomic = AtomicValue < DataStoreCategory > ( initialValue: DataStoreCategory ( ) )
61+ public static internal( set) var DataStore : DataStoreCategory {
62+ get { dataStoreAtomic. get ( ) }
63+ set { dataStoreAtomic. set ( newValue) }
64+ }
4665
4766 /// - Tag: Amplify.Geo
48- public static internal( set) var Geo = GeoCategory ( )
67+ private static let geoAtomic = AtomicValue < GeoCategory > ( initialValue: GeoCategory ( ) )
68+ public static internal( set) var Geo : GeoCategory {
69+ get { geoAtomic. get ( ) }
70+ set { geoAtomic. set ( newValue) }
71+ }
4972
5073 /// - Tag: Amplify.Hub
51- public static internal( set) var Hub = HubCategory ( )
74+ private static let hubAtomic = AtomicValue < HubCategory > ( initialValue: HubCategory ( ) )
75+ public static internal( set) var Hub : HubCategory {
76+ get { hubAtomic. get ( ) }
77+ set { hubAtomic. set ( newValue) }
78+ }
5279
5380 /// - Tag: Amplify.Notifications
54- public static internal( set) var Notifications = NotificationsCategory ( )
81+ private static let notificationsAtomic = AtomicValue < NotificationsCategory > ( initialValue: NotificationsCategory ( ) )
82+ public static internal( set) var Notifications : NotificationsCategory {
83+ get { notificationsAtomic. get ( ) }
84+ set { notificationsAtomic. set ( newValue) }
85+ }
5586
5687 /// - Tag: Amplify.Predictions
57- public static internal( set) var Predictions = PredictionsCategory ( )
88+ private static let predictionsAtomic = AtomicValue < PredictionsCategory > ( initialValue: PredictionsCategory ( ) )
89+ public static internal( set) var Predictions : PredictionsCategory {
90+ get { predictionsAtomic. get ( ) }
91+ set { predictionsAtomic. set ( newValue) }
92+ }
5893
5994 /// - Tag: Amplify.Storage
60- public static internal( set) var Storage = StorageCategory ( )
95+ private static let storageAtomic = AtomicValue < StorageCategory > ( initialValue: StorageCategory ( ) )
96+ public static internal( set) var Storage : StorageCategory {
97+ get { storageAtomic. get ( ) }
98+ set { storageAtomic. set ( newValue) }
99+ }
61100
62101 /// Special case category. We protect this with an AtomicValue because it is used by reset()
63102 /// methods during setup & teardown of tests
0 commit comments