rick
rick

Reputation: 1057

Using Async Task in a Serial Queue

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

Answers (1)

Durdu
Durdu

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.

enter image description here enter image description here

In the example from the image "Async on some thread" will always be printed before "sync" because the myQueue is serial

Upvotes: 1

Related Questions