Conversation
DVR/SessionDataTask.swift
Outdated
There was a problem hiding this comment.
I stopped to wonder if we should call this all in this queue or just call the completion callback in this queue. I think both cases are valid and both accomplish the same thing, but putting all this in a block seems like a bigger hammer than needed, but probably simulates closer to what NSURLSession might be doing.
I'm curious what might be best!
There was a problem hiding this comment.
hmm I agree that its a bigger hammer than needed. I'll update accordingly
There was a problem hiding this comment.
I don't know if either is better, TBH. I think doing all this work on another queue might better simulate a network request.
Just wanted to raise my thought process, honestly.
as opposed to the calling thread, in order to better mimic NSURLSessionDataTask functionality
|
@eliperkins We now call the completion on the queue only. |
DVR/SessionDataTask.swift
Outdated
There was a problem hiding this comment.
Should we create a new queue for every data task? Would it may be better to have just one static queue on which these tasks run?
There was a problem hiding this comment.
I thought NSURLSession's queue's were nondeterministic so I wanted to replicate that here. Performance really is not really too important here, since we're only using this in tests (and the drop in performance of creating a new queue on each request is probably insignificant)
That said, I'm open to creating a static queue.
There was a problem hiding this comment.
Not sure which aspect of the queue you mean when you say non-deterministic. Either way, a session manages just one queue for its lifetime so I think mirroring that within our own Session object would make sense.
There was a problem hiding this comment.
a session manages just one queue for its lifetime so I think mirroring that within our own Session object would make sense.
TIL. Updated here: 0262a86
SessionDataTask's resume does work on a new background thread...
as opposed to the calling thread, in order to better mimic NSURLSessionDataTask functionality