Monday, May 8, 2017

Fast Stuff on a Background GCD Queue

I realize this is not a popular position, but the truth of the matter is that for many (most) situations, you can just do stuff on a background queue and then dispatch the main queue. It's pretty hard (but not impossible) to clog up the main dispatch queue.

NSTimer Replacement: Faster!

Here's my timer for running stuff in the background. Generally, this is all you need. Dispatch to main from within your callback as needed:


Get on Main Queue the Right Way

On the other hand, if you want to do this right and never risk clogging up the main queue, you need to use a dispatch source. See Rob's stuff here on SO, particularly the last part where he discusses a progressIndicator.

GameLoop for MainQueue Dispatch Tied to Frame Rate

On the other hand, if you want something to update every time the main loop goes around, you can use this Game Loop:

No comments: