PMHTTP icon indicating copy to clipboard operation
PMHTTP copied to clipboard

Parse block should run on .default QoS, be configurable

Open lilyball opened this issue 6 years ago • 0 comments

Right now request parse blocks run on .utility (unless request.userInitiated == true, then it runs on the .userInitiated queue). We should probably change that to .default instead, and have some way to configure it. Configuration should be limited to just QoS rather than specifying explicit queues (notably, we take the position that parse blocks should never run on the main queue, and if you really need that you should parse in the completion block; this decision was made to encourage users to not require parsing on the main thread, as we try and do as little work as possible on the main thread).

I'm not sure offhand how to bump the QoS automatically to .userInitiated with a configurable queue. We could overload all the parse methods to have separate versions that take a QoS or not, and do the automatic bumping only if the QoS isn't specified, but this would be annoying duplication and also be a bit of an ergonomic issue for anyone writing their own custom convenience parse methods. We could also just make the QoS optional, and do the automatic prioritizing if it's nil. Or we could just default it to .default and them bump it to .userInitiated if request.userInitiated == true and the QoS is specified as anything other than .userInteractive. I'm tempted to go this route, because if request.userInitiated == true then it seems odd to parse on anything lower, and this way a convenience parse wrapper can just specify whatever QoS they want without worrying if their caller will set request.userInitiated = true.

lilyball avatar Nov 12 '18 23:11 lilyball