Skip to content
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

renderQueue? #27

Closed
steipete opened this issue Aug 25, 2011 · 9 comments
Closed

renderQueue? #27

steipete opened this issue Aug 25, 2011 · 9 comments

Comments

@steipete
Copy link
Contributor

Hi guys,

i finally have time to look into KKGridView, and already found/working on some issues.

I'm curious, what's the reasoning behind renderQueue and the dispatch_sync? (_layoutGridView, KKGridView.mm)
I've never seen such a pattern - AFAIK you're not allowed to make UIKit-changes except in the main thread, so we're already guaranteed that no two render operations run at the same time. Am I overlooking sth?

@kolinkrewinkel
Copy link
Owner

The render queue assures that the cells are rendered synchronously, in order, and with the highest priority. The threading assures the app is free to do whatever it needs with as little possible interruption from the grid. We noticed a moderate performance increase with this.

@jonsterling
Copy link
Collaborator

I'd like more discussion on this. At first glance, Peter appears to be right, since sending UIKit messages on a thread other than the main thread is documented as a no-no.

@kolinkrewinkel
Copy link
Owner

This queue is on the main thread AFAIK otherwise the UI wouldn't update at all.

@jonsterling
Copy link
Collaborator

Sounds reasonable. Can you find it documented that serial queues execute on the main thread?

Edit: Unless you find something to the contrary, I don't think it's actually guaranteed that serial queues will execute on the main thread. Hence, to be safe, we probably ought to wrap all UIKit updates in dispatch_async(dispatch_get_main_queue(), ^{}); blocks.

@kolinkrewinkel
Copy link
Owner

I'll ask Indragie. I got the idea from him.

@steipete
Copy link
Contributor Author

Still, i'm not convinced that there's any advantage in using such a queue. Performance-wise, all it should bring is a slightly speed loss, GCD is fast, but there's still some overhead.

@jonsterling
Copy link
Collaborator

Only way to find out is to test. The reason we're using a queue in the first place is that @kolinkrewinkel believed that it resulted in a net speed increase when he tried it. If that's no longer the case, it should be excised.

@Gi-lo
Copy link
Contributor

Gi-lo commented Aug 26, 2011

I think what the queue does is bundling all the update actions and put it at the end of the main runloop. I may be wrong though...

@steipete
Copy link
Contributor Author

No, it doesn't. If you use dispatch_sync, it's executed right within the code flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants