@@ -20,44 +20,83 @@ import Foundation
20
20
/// available at initialization.
21
21
///
22
22
/// - Tag: Amplify
23
- public class Amplify {
23
+ public class Amplify : @ unchecked Sendable {
24
24
25
25
/// If `true`, `configure()` has already been invoked, and subsequent calls to `configure` will throw a
26
26
/// ConfigurationError.amplifyAlreadyConfigured error.
27
27
///
28
28
/// - 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
+ }
30
34
31
35
// 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.
34
37
35
38
/// - 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
+ }
37
44
38
45
/// - 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
+ }
40
51
41
52
/// - 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
+ }
43
58
44
59
/// - 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
+ }
46
65
47
66
/// - 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
+ }
49
72
50
73
/// - 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
+ }
52
79
53
80
/// - 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
+ }
55
86
56
87
/// - 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
+ }
58
93
59
94
/// - 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
+ }
61
100
62
101
/// Special case category. We protect this with an AtomicValue because it is used by reset()
63
102
/// methods during setup & teardown of tests
0 commit comments