Mark managed atomic constructs Sendable if their payloads are

This commit is contained in:
Karoy Lorentey committed 2021-09-30 13:08:00 -07:00
1 parent 919eb1d83e
commit e220ff33c3
4 files changed
+16

No files matched your search

@@ -152,6 +152,11 @@ public class ManagedAtomicLazyReference<Instance: AnyObject> {
}
}
#if compiler(>=5.5) && canImport(_Concurrency)
extension ManagedAtomicLazyReference: @unchecked Sendable
where Instance: Sendable {}
#endif
% for type in ["UnsafeAtomicLazyReference", "ManagedAtomicLazyReference"]:
extension ${type} {
/// Atomically initializes this reference if its current value is nil, then
+3
View File
@@ -99,6 +99,9 @@ public class ManagedAtomic<Value: AtomicValue> {
}
}
#if compiler(>=5.5) && canImport(_Concurrency)
extension ManagedAtomic: @unchecked Sendable where Value: Sendable {}
#endif
% for type in ["UnsafeAtomic", "ManagedAtomic"]:
extension ${type} {
@@ -155,6 +155,11 @@ public class ManagedAtomicLazyReference<Instance: AnyObject> {
}
}
#if compiler(>=5.5) && canImport(_Concurrency)
extension ManagedAtomicLazyReference: @unchecked Sendable
where Instance: Sendable {}
#endif
extension UnsafeAtomicLazyReference {
/// Atomically initializes this reference if its current value is nil, then
/// returns the initialized value. If this reference is already initialized,
@@ -101,6 +101,9 @@ public class ManagedAtomic<Value: AtomicValue> {
}
}
#if compiler(>=5.5) && canImport(_Concurrency)
extension ManagedAtomic: @unchecked Sendable where Value: Sendable {}
#endif
extension UnsafeAtomic {
/// Atomically loads and returns the current value, applying the specified