From a6d862e6aa2ffc4bd3e771c52847a38575ef717e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Bu=CC=88gling?= Date: Wed, 25 Mar 2015 16:44:42 +0100 Subject: [PATCH] Use a private serial queue for image decompression Fixes #3 --- Code/CCBufferedImageView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/CCBufferedImageView.swift b/Code/CCBufferedImageView.swift index c5bfd73..c9dde7e 100644 --- a/Code/CCBufferedImageView.swift +++ b/Code/CCBufferedImageView.swift @@ -13,6 +13,7 @@ public class CCBufferedImageView : UIImageView, NSURLConnectionDataDelegate { private weak var connection: NSURLConnection? private let defaultContentLength = 5 * 1024 * 1024 private var data: NSMutableData? + private let queue = dispatch_queue_create("com.contentful.Concorde", DISPATCH_QUEUE_SERIAL) /// Optional handler which is called after an image has been successfully downloaded public var loadedHandler: (() -> ())? @@ -58,7 +59,7 @@ public class CCBufferedImageView : UIImageView, NSURLConnectionDataDelegate { public func connection(connection: NSURLConnection, didReceiveData data: NSData) { self.data?.appendData(data) - dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { + dispatch_sync(queue) { let decoder = CCBufferedImageDecoder(data: self.data) decoder.decompress() let decodedImage = decoder.toImage()