See how Dispatch can let you run regularly scheduled work in only a few lines of code.
Soroush Khanlou has published a new article giving some helpful tips for using Grand Central Dispatch (GCD) in server-side Swift apps.
After explaining why it’s needed (“The main queue is blocked, constantly spinning, in order to prevent the program from ending”), Soroush goes on to provide examples of dispatch semaphores and timers that are simple enough you can start using them straight away.
While there’s a broader discussion to be had about actors in Swift in the future, spurred by Chris Lattner’s concurrency manifesto, and perhaps in the future, and some of the patterns for asynchronous workers will change, for now, Dispatch is the best tool that we have.
Link: Dispatch On The Server.
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.