1 Reply
      Latest reply on Aug 29, 2019 1:15 AM by eskimo
      bduggan Level 1 Level 1 (0 points)

        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?