dispatch_sync vs. dispatch_async on main queue

前端 未结 3 1341
北恋
北恋 2021-01-29 23:20

Bear with me, this is going to take some explaining. I have a function that looks like the one below.

Context: \"aProject\" is a Core Data entity named LPProject with an

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 00:19

    I think it is more easy to understand with diagram:

    For the situation the author described:

    |taskQ| ***********start|

    |dispatch_1 ***********|---------

    |dispatch_2 *************|---------

    .

    |dispatch_n ***************************|----------

    |main queue(sync)|**start to dispatch to main|

    *************************|--dispatch_1--|--dispatch_2--|--dispatch3--|*****************************|--dispatch_n|,

    which make the sync main queue so busy that finally fail the task.

提交回复
热议问题