Reputation: 1057
Is it possible to add a async task in a Serial queue?
I want to know if you create a serial queue, and add some async tasks, does this queue treat these async tasks as sync tasks?
Upvotes: 4
Views: 1301
Reputation: 4849
A serial queue will wait for the previous operation to finish.
From the actual documentation:
Serial queues ... execute one task at a time in the order in which they are added to the queue. The currently executing task runs on a distinct thread (which can vary from task to task) that is managed by the dispatch queue. ...
You can have operations that run "async" but they will be serial.
In the example from the image "Async on some thread" will always be printed before "sync" because the myQueue is serial
Upvotes: 1