10.2 · Operation, OperationQueue, dependencies and cancellation

OperationQueue is GCD with a vocabulary: units of work that have dependencies, a state and the ability to be cancelled. It is still the right tool when those matter.

Mental model. An operation is a unit of work with a lifecycle. Use it when you need to order, limit, observe or cancel work, and use a plain queue when you do not.

Operations

Dependencies, lifecycle and cancellation, and how it compares to GCD.

  1. When do you use OperationQueue instead of GCD, and how do dependencies, state and cancellation work? 10.2.1 · L3
    An Operation (usually a BlockOperation or your subclass) has a state machine: ready, executing, finished, with isCancelled as a flag. An OperationQueue runs…

More in Concurrency