Skip to content

Commit

Permalink
Improve queue usage
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcferreira committed Nov 3, 2020
1 parent 83f426e commit 651899a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/GIFPublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fileprivate class GIFSubscription<Target: Subscriber>: Subscription where Target
let combineIdentifier: CombineIdentifier = CombineIdentifier(UUID().uuidString as NSString)

let currentFrame: Int = 0
let delayQueue = DispatchQueue(label: "GIFSubscription", qos: .background)
let frames: [GIFFrame]
var target: Target?

Expand All @@ -44,8 +43,10 @@ fileprivate class GIFSubscription<Target: Subscriber>: Subscription where Target
guard frame < frames.count else { return finish() }
let gifFrame = frames[frame]
let _ = target.receive(gifFrame)
delayQueue.asyncAfter(deadline: .now() + gifFrame.delay) { [weak self] in
self?.trigger(frame: frame + 1)
DispatchQueue
.global(qos: .userInteractive)
.asyncAfter(deadline: .now() + gifFrame.delay) { [weak self] in
self?.trigger(frame: frame + 1)
}
}
}
Expand Down

0 comments on commit 651899a

Please sign in to comment.