Skip to content

Commit

Permalink
Use a private serial queue for image decompression
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
neonichu committed Mar 25, 2015
1 parent 5fbcb33 commit a6d862e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Code/CCBufferedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: (() -> ())?
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a6d862e

Please sign in to comment.