Tutorial by Examples

You can create your own queue using dispatch_queue_create Objective-C dispatch_queue_t queue = dispatch_queue_create("com.example.myqueue", DISPATCH_QUEUE_SERIAL); Swift // Before Swift 3 let queue = dispatch_queue_create("com.example.myqueue", DISPATCH_QUEUE_SERIAL) // ...
The main queue is the dispatch queue in which all the UI updates take place and the code involving UI changes are placed. You need to get to the main queue in order to update UI on completion of an asynchronous process like NSURLSession There are two types of main queue calls synchronous and async...
DispatchGroup allows for aggregate synchronization of work. You can use them to submit multiple different work items and track when they all complete, even though they might run on different queues. This behavior can be helpful when progress can’t be made until all of the specified tasks are c...
DispatchSemaphore provides an efficient implementation of a traditional counting semaphore, which can be used to control access to a resource across multiple execution contexts. A scenario for when to use a semaphore could be if you are doing some file reading/writing, if multiple tasks are t...
Swift 3 Serial Queue func serialQueues () { let serialQueue = DispatchQueue(label: "com.example.serial") //default queue type is a serial queue let start = Date () for i in 0...3 { //launch a bunch of tasks serialQueue.a...

Page 1 of 1