Browse Source

Refine sendable for some types

onevcat 1 year ago
parent
commit
fa53d263b8

+ 1 - 1
Sources/General/KingfisherOptionsInfo.swift

@@ -359,7 +359,7 @@ public enum KingfisherOptionsInfoItem {
 /// Each property in this type corresponds to a case member in ``KingfisherOptionsInfoItem``. When a
 /// Each property in this type corresponds to a case member in ``KingfisherOptionsInfoItem``. When a
 ///  ``KingfisherOptionsInfo`` is sent to Kingfisher-related methods, it will be parsed and converted to a
 ///  ``KingfisherOptionsInfo`` is sent to Kingfisher-related methods, it will be parsed and converted to a
 ///  ``KingfisherParsedOptionsInfo`` first before passing through the internal methods.
 ///  ``KingfisherParsedOptionsInfo`` first before passing through the internal methods.
-public struct KingfisherParsedOptionsInfo: Sendable {
+public struct KingfisherParsedOptionsInfo: @unchecked Sendable {
 
 
     public var targetCache: ImageCache? = nil
     public var targetCache: ImageCache? = nil
     public var originalCache: ImageCache? = nil
     public var originalCache: ImageCache? = nil

+ 1 - 1
Sources/Utility/DisplayLink.swift

@@ -52,7 +52,7 @@ extension UIView {
     }
     }
 }
 }
 
 
-extension CADisplayLink: DisplayLinkCompatible {}
+extension CADisplayLink: DisplayLinkCompatible, @unchecked Sendable {}
 
 
 #else
 #else
 extension NSView {
 extension NSView {

+ 3 - 2
Sources/Views/AnimatedImageView.swift

@@ -436,6 +436,7 @@ open class AnimatedImageView: KFCrossPlatformImageView {
     private var currentFrame: KFCrossPlatformImage?
     private var currentFrame: KFCrossPlatformImage?
     
     
     /// Update the current frame with the displayLink duration.
     /// Update the current frame with the displayLink duration.
+    @MainActor
     private func updateFrameIfNeeded() {
     private func updateFrameIfNeeded() {
         guard let animator = animator else {
         guard let animator = animator else {
             return
             return
@@ -520,7 +521,6 @@ extension AnimatedImageView {
     // MARK: - Animator
     // MARK: - Animator
 
 
     /// An animator which is used to drive the data behind ``AnimatedImageView``.
     /// An animator which is used to drive the data behind ``AnimatedImageView``.
-    @MainActor
     public class Animator {
     public class Animator {
         private let size: CGSize
         private let size: CGSize
 
 
@@ -684,6 +684,7 @@ extension AnimatedImageView {
             }
             }
         }
         }
 
 
+        @MainActor 
         func shouldChangeFrame(with duration: CFTimeInterval) -> Bool {
         func shouldChangeFrame(with duration: CFTimeInterval) -> Bool {
             incrementTimeSinceLastFrameChange(with: duration)
             incrementTimeSinceLastFrameChange(with: duration)
 
 
@@ -768,7 +769,7 @@ extension AnimatedImageView {
             }
             }
         }
         }
 
 
-        private func incrementCurrentFrameIndex() {
+        @MainActor private func incrementCurrentFrameIndex() {
             let wasLastFrame = isLastFrame
             let wasLastFrame = isLastFrame
             currentFrameIndex = increment(frameIndex: currentFrameIndex)
             currentFrameIndex = increment(frameIndex: currentFrameIndex)
             if isLastFrame {
             if isLastFrame {