Skip to content

Commit a6d862e

Browse files
committed
Use a private serial queue for image decompression
Fixes #3
1 parent 5fbcb33 commit a6d862e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Code/CCBufferedImageView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CCBufferedImageView : UIImageView, NSURLConnectionDataDelegate {
1313
private weak var connection: NSURLConnection?
1414
private let defaultContentLength = 5 * 1024 * 1024
1515
private var data: NSMutableData?
16+
private let queue = dispatch_queue_create("com.contentful.Concorde", DISPATCH_QUEUE_SERIAL)
1617

1718
/// Optional handler which is called after an image has been successfully downloaded
1819
public var loadedHandler: (() -> ())?
@@ -58,7 +59,7 @@ public class CCBufferedImageView : UIImageView, NSURLConnectionDataDelegate {
5859
public func connection(connection: NSURLConnection, didReceiveData data: NSData) {
5960
self.data?.appendData(data)
6061

61-
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
62+
dispatch_sync(queue) {
6263
let decoder = CCBufferedImageDecoder(data: self.data)
6364
decoder.decompress()
6465
let decodedImage = decoder.toImage()

0 commit comments

Comments
 (0)