How to dispatch code blocks to the same thread in iOS?

前端 未结 8 1676
广开言路
广开言路 2021-01-31 11:04

Main aspect of the question: It\'s about iOS. Can I somehow dispatch code blocks in a way, that they will all (a) run in background and (b) on the same thread?

8条回答
  •  清酒与你
    2021-01-31 11:26

    In GCD: no, that's not possible with the current lib dispatch.

    Blocks can be executed by dispatch lib on whatever thread which is available, no matter to which queue they have been dispatched.

    One exception is the main queue, which always executes its blocks on the main thread.

    Please file a feature request to Apple, since it seems justified and sound. But I fear it's not feasible, otherwise it would already exist ;)

提交回复
热议问题