Friday, April 11, 2014

Dispatch queue, Operation queue difference

Both dispatch queue and operation queue in Grand Central Dispatch (GCD) are available for ios development for handling asynchronous operation, and each has its own features.

Operation queue is a higher level API than dispatch queue, it is based on objective-c, so it is ARC ready. It only supports concurrent operation, although with addDependency method, it can define the dependency between operations and make them happen sequentially. It also supports operation priority, so a new operation with high priority may run before other operation added earlier in the queue. An completion block can be used to do some work which is not part of operation task.

Dispatch queue is based on c API, it supports block for task. It supports both concurrent queue and serial queue (private dispatch queue), and Main dispatch queue. Dispatch queue does not provide method to get queued item count or cancel queued item. If it is required to cancel all queued item in serial queue, one option is adding a sync item with empty completion block, if is called, then we know all previous items have been processed.

2 comments:

  1. I love this. It is soo informative. Are you also searching for cheap assignment writing service uk we are the best solution for you. We are best known for delivering the best services to students without having to break the bank

    ReplyDelete
  2. I love this. It is soo informative. Are you also searching for swedish assignment writers we are the best solution for you. We are best known for delivering the best services to students without having to break the bank

    ReplyDelete