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 Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until February 9th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.