Procházet zdrojové kódy

Refine sendable for some types

onevcat před 1 rokem
rodič
revize
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
 ///  ``KingfisherOptionsInfo`` is sent to Kingfisher-related methods, it will be parsed and converted to a
 ///  ``KingfisherParsedOptionsInfo`` first before passing through the internal methods.
-public struct KingfisherParsedOptionsInfo: Sendable {
+public struct KingfisherParsedOptionsInfo: @unchecked Sendable {
 
     public var targetCache: 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
 extension NSView {

+ 3 - 2
Sources/Views/AnimatedImageView.swift

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