|
|
@@ -103,19 +103,25 @@ final class ImageProgressiveProvider: DataReceivingSideEffect {
|
|
|
self.refresh(image)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ let semaphore = DispatchSemaphore(value: 0)
|
|
|
+ var onShouldApply: Bool = false
|
|
|
+
|
|
|
+ CallbackQueue.mainAsync.execute {
|
|
|
+ onShouldApply = self.onShouldApply()
|
|
|
+ semaphore.signal()
|
|
|
+ }
|
|
|
+ semaphore.wait()
|
|
|
+ guard onShouldApply else {
|
|
|
+ self.queue.clean()
|
|
|
+ completion()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- CallbackQueue.mainCurrentOrAsync.execute {
|
|
|
- guard self.onShouldApply() else {
|
|
|
- self.queue.clean()
|
|
|
- completion()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if self.option.isFastestScan {
|
|
|
- decode(self.decoder.scanning(data) ?? Data())
|
|
|
- } else {
|
|
|
- self.decoder.scanning(data).forEach { decode($0) }
|
|
|
- }
|
|
|
+ if self.option.isFastestScan {
|
|
|
+ decode(self.decoder.scanning(data) ?? Data())
|
|
|
+ } else {
|
|
|
+ self.decoder.scanning(data).forEach { decode($0) }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -256,8 +262,7 @@ private final class ImageProgressiveDecoder {
|
|
|
private final class ImageProgressiveSerialQueue {
|
|
|
typealias ClosureCallback = ((@escaping () -> Void)) -> Void
|
|
|
|
|
|
- private let queue: DispatchQueue = //DispatchQueue.main
|
|
|
- .init(label: "com.onevcat.Kingfisher.ImageProgressive.SerialQueue")
|
|
|
+ private let queue: DispatchQueue = .init(label: "com.onevcat.Kingfisher.ImageProgressive.SerialQueue")
|
|
|
private var items: [DispatchWorkItem] = []
|
|
|
private var notify: (() -> Void)?
|
|
|
private var lastTime: TimeInterval?
|