Remove lock tradeoff when get fetchFrame
This commit is contained in:
parent
6d85cd9061
commit
759b7322c9
|
@ -689,8 +689,10 @@ static NSUInteger SDDeviceFreeMemory() {
|
||||||
|
|
||||||
// Update the current frame
|
// Update the current frame
|
||||||
UIImage *currentFrame;
|
UIImage *currentFrame;
|
||||||
|
UIImage *fetchFrame;
|
||||||
LOCKBLOCK({
|
LOCKBLOCK({
|
||||||
currentFrame = self.frameBuffer[@(currentFrameIndex)];
|
currentFrame = self.frameBuffer[@(currentFrameIndex)];
|
||||||
|
fetchFrame = currentFrame ? self.frameBuffer[@(nextFrameIndex)] : nil;
|
||||||
});
|
});
|
||||||
BOOL bufferFull = NO;
|
BOOL bufferFull = NO;
|
||||||
if (currentFrame) {
|
if (currentFrame) {
|
||||||
|
@ -744,11 +746,6 @@ static NSUInteger SDDeviceFreeMemory() {
|
||||||
fetchFrameIndex = nextFrameIndex;
|
fetchFrameIndex = nextFrameIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIImage *fetchFrame;
|
|
||||||
LOCKBLOCK({
|
|
||||||
fetchFrame = self.frameBuffer[@(fetchFrameIndex)];
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!fetchFrame && !bufferFull && self.fetchQueue.operationCount == 0) {
|
if (!fetchFrame && !bufferFull && self.fetchQueue.operationCount == 0) {
|
||||||
// Prefetch next frame in background queue
|
// Prefetch next frame in background queue
|
||||||
UIImage<SDAnimatedImage> *animatedImage = self.animatedImage;
|
UIImage<SDAnimatedImage> *animatedImage = self.animatedImage;
|
||||||
|
|
Loading…
Reference in New Issue