Skip to content

Commit

Permalink
Merge pull request #48 from lorentey/fix-UnsafeAtomic-Sendable
Browse files Browse the repository at this point in the history
Fix `UnsafeAtomic`'s `Sendable` conformance
  • Loading branch information
lorentey authored Sep 24, 2021
2 parents de1a622 + 44bf6b5 commit 919eb1d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/Atomics/AtomicLazyReference.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public struct UnsafeAtomicLazyReference<Instance: AnyObject> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension UnsafeAtomicLazyReference: @unchecked Sendable
where Instance: Sendable {}
#endif

extension UnsafeAtomicLazyReference {
/// The storage representation for an atomic lazy reference value.
@frozen
Expand Down
4 changes: 4 additions & 0 deletions Sources/Atomics/HighLevelTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public struct UnsafeAtomic<Value: AtomicValue> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension UnsafeAtomic: @unchecked Sendable where Value: Sendable {}
#endif

/// A reference type holding an atomic value, with automatic memory management.
@_fixed_layout
public class ManagedAtomic<Value: AtomicValue> {
Expand Down
5 changes: 5 additions & 0 deletions Sources/Atomics/autogenerated/AtomicLazyReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public struct UnsafeAtomicLazyReference<Instance: AnyObject> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension UnsafeAtomicLazyReference: @unchecked Sendable
where Instance: Sendable {}
#endif

extension UnsafeAtomicLazyReference {
/// The storage representation for an atomic lazy reference value.
@frozen
Expand Down
4 changes: 4 additions & 0 deletions Sources/Atomics/autogenerated/HighLevelTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public struct UnsafeAtomic<Value: AtomicValue> {
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
extension UnsafeAtomic: @unchecked Sendable where Value: Sendable {}
#endif

/// A reference type holding an atomic value, with automatic memory management.
@_fixed_layout
public class ManagedAtomic<Value: AtomicValue> {
Expand Down

0 comments on commit 919eb1d

Please sign in to comment.