This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9461083-ios-concurrency-with-gcd-and-operations/lessons/3
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9461083-ios-concurrency-with-gcd-and-operations/lessons/3
sync
you want to prevent other tasks from running while this task is running
Thank you. Please correct it in the video
sorry, it’s been a while, and it’s easy to get confused …
that code dispatches to a serial queue, so tasks on internalQueue
run in the order they arrive. If you dispatch a write task, followed by a read task, the read task must wait its turn on internalQueue
.
whether you dispatch sync or async doesn’t affect the fact that the tasks on internalQueue
run serially.
sync or async affects the queue you’re dispatching from — whether or not it waits for the task to finish before continuing. You want to wait for a read task to complete before you continue, because you need the value it’s reading. You don’t need to wait for a write task, because it’s not returning any value.
Where did you find that slide? I can’t find it in the files for any of this part’s videos.