How to create a GCD queue, which is always serial, even on multi-core processors?

As far as I understand, GCD queues with a non-standard queue are by default serial only on devices with single-core processors. But if the device has several cores, it may happen that the blocks in the queue are executed simultaneously.

I want to use a sequential GCD queue to solve some concurrency problems, and this queue should be sequential even if there are several cores.

The developer noted that this is possible. How to create such an always-sequential queue?

+5
source share
2 answers

GCD, dispatch_get_global_queue, .

gcd, dispatch_queue_create. DISPATCH_QUEUE_SERIAL .

+9

:
dispatch_queue_t concurrentQueue = dispatch_queue_create("com.aj.concurrent.queue", DISPATCH_QUEUE_CONCURRENT);

:
dispatch_queue_t serialQueue = dispatch_queue_create("com.aj.serial.queue", DISPATCH_QUEUE_SERIAL);

+6

All Articles