https://cocoacasts.com
https://cocoacasts.com/series/masteri...
You've probably heard about Grand Central Dispatch and chances are that you've used it in some of your projects. This series takes a close look at Grand Central Dispatch. Before exploring the API of Grand Central Dispatch, we find out what it is and what problem it solves.
What Is Grand Central Dispatch?
Before you start using Grand Central Dispatch, it's important that you become familiar with the underlying technology. What is Grand Central Dispatch? What problem does it solve? And why should you be using it?
Most modern computing devices are powered by capable, multicore processors. The availability of multiple cores allows these devices to execute work concurrently, that is, at the same time. That enables your phone to download a video in the background while keeping the user interface responsive.
Most applications support a wide range of devices. How can you optimize your application to take advantage of the multicore hardware it runs on? That's where Grand Central Dispatch comes into play.
Apple introduced Grand Central Dispatch almost ten years ago. It first made its appearance in Mac OS X Snow Leopard. Today, it's available on iOS, tvOS, macOS, and watchOS. Grand Central Dispatch makes it easier to write multithreaded code, regardless of the platform or device your application runs on.
Grand Central Dispatch is a technology that is designed to make the execution of tasks on multicore hardware performant and straightforward. It can do this because it operates at the system level. Your application operates in a sandbox, which means that it is unaware of other processes running on the system at the same time. Because Grand Central Dispatch operates at the system level, it has an accurate view of the processes that are running and the resources that are available.
By leveraging Grand Central Dispatch, your application doesn't need to know about the platform or device it runs on. It doesn't need to take other processes competing for the same resources into account. Grand Central Dispatch allows applications to schedule work for execution through an easy to use API. It's the task of Grand Central Dispatch to decide when and how the scheduled work is executed.