Can somebody explain to me exactly what DISPATCH_QUEUE_OVERCOMMIT is

I have asked a similar question https://stackoverflow.com/questions/57673551/what-exactly-is-gcd-overcommit-and-is-it-dangerous?noredirect=1#comment101796081_57673551



I'm trying to understand what exactly an over commit queue is and if my code is dangerous because I'm seeing it referenced in my console.



I started out wanting to create my thread with a run loop to do some experiments with realm and it's thread confinement.



There's a nice example https://github.com/duemunk/Thread



In my code I make use of



__dispatch_queue_get_label


to print out the label of the queue I'm working on for debugging purposes.



When ever I print this queue label from inside enqueuing on my custom thread it prints out



com.apple.root.default-qos.overcommit


Here's a small example of my test code




func currentQueueName() -> String? {
        let name = __dispatch_queue_get_label(nil)
        return String(cString: name, encoding: .utf8)
    }




DispatchQueue.global().async {
            print(self.currentQueueName())
            myThread.enqueue {
                print(self.currentQueueName())
                //prints "com.apple.root.default-qos.overcommit"
                for i in 1...100 {
                    print(i)
                }
            }
        }





So my question really is, is my code safe?

Is the overcommit queue just another normal type of queue in swift but one that is not managed directly by GCD?



My (flakey)understanding of the over commit queue so far is that its a queue that doesn't try to limit the amount of threads spawned on it. Is that right?

Replies

I’m going to start by pointing you at this thread. Please read that through and post back if you have further questions.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"