Is DispatchQueue.global(qos: .userInteractive).async same as DispatchQueue.main.async

前端 未结 5 1685
一整个雨季
一整个雨季 2020-12-30 19:09

I was going through the tutorial : https://www.raywenderlich.com/148513/grand-central-dispatch-tutorial-swift-3-part-1

And came across the definition of QoS class

5条回答
  •  Happy的楠姐
    2020-12-30 19:31

    Anyone who says the .userInitiated global queue is the main thread is just wrong. It's a very high priority background queue, but it is a background queue (and it is concurrent, unlike the main thread).

    Apple's own sample code and comments make the matter quite clear:

    // This handler gets called on the main thread; dispatch to a background queue for processing.
    DispatchQueue.global(qos: .userInitiated).async {
    

    This proves beyond a shadow of a doubt that Apple believes the .userInitiated global queue is a "background queue" and not the "main thread".

提交回复
热议问题