-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for request priorities #666
Conversation
We have, but I think those might be too many priorities. This is the same problem as log levels. Everyone wants a lower log level or a higher log level because they abuse them. I wanted only two, but I can probably be convinced for three. I don't think I can be convinced of four. |
@@ -69,6 +74,7 @@ | |||
|
|||
BitmapHunter(Picasso picasso, Dispatcher dispatcher, Cache cache, Stats stats, Action action, | |||
RequestHandler requestHandler) { | |||
this.sequence = SEQUENCE_GENERATOR.addAndGet(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incrementAndGet()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@JakeWharton Fair enough. Let's start with just LOW, NORMAL, HIGH then. I think using only two priorities feels too "polarizing". Three gives enough flexibility for more complex cases. |
Updated branch:
|
👍 👍 👍 One of the more challenging things I'd like to figure out is a way to limit the number of threads on which |
Implement support for request priorities
👍 well done @lucasr |
Not sure if you've considered something like this in the past but here it is. This patch implements request priority support in Picasso. This feature can be especially handy when you have UIs with lots of images and you want to have tighter control over which images should load first. This is inspired by Volley's API.
It adds a new API in
RequestCreator
to define the request priority:Priority can be
LOW
,NORMAL
,HIGH
, orIMMEDIATE
.BitmapHunters
compute their priority in the executor by taking the highest priority of its attached requests. For example, if aBitmapHunter
has two attachedActions
, oneLOW
and and oneHIGH
priority, its priority will beHIGH
.