Skip to content

Commit

Permalink
Merge pull request #26 from venmo/daz/queue
Browse files Browse the repository at this point in the history
SessionDataTask's resume does work on a new background thread...
  • Loading branch information
dasmer committed Sep 23, 2015
2 parents d196b57 + 0262a86 commit 48059cc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion DVR/SessionDataTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SessionDataTask: NSURLSessionDataTask {
weak var session: Session!
let request: NSURLRequest
let completion: Completion?
private let queue = dispatch_queue_create("com.venmo.DVR.sessionDataTaskQueue", nil)


// MARK: - Initializers
Expand All @@ -35,7 +36,11 @@ class SessionDataTask: NSURLSessionDataTask {
// Find interaction
if let interaction = cassette?.interactionForRequest(request) {
// Forward completion
completion?(interaction.responseData, interaction.response, nil)
if let completion = completion {
dispatch_async(queue) {
completion(interaction.responseData, interaction.response, nil)
}
}
return
}

Expand Down

0 comments on commit 48059cc

Please sign in to comment.