We saw in the last recipe how Dispatch Queues operate on a first in first out policy; Grand Central Dispatch (GCD) will execute a block from the top of the queue, and remove it from the queue when it has finished executing. The number of blocks that GCD will allow to execute at the same time will depend on the type of queue being used. Serial queues will only have one block of code being executed at any time; other blocks in the queues will have to wait until the block at the top of the queue has finished executing. However, for a concurrent queue, GCD will concurrently execute as many blocks as there are resources available. We can make more efficient use of a concurrent queue by breaking down the work into smaller, independent ...
How to do it...
Get Swift 4 Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.