Reputation: 72
I am learning how to make sync and asyn operations . Please correct me what i have mentioned/learned are right:
sync and asyn operations can be done in following ways(we can pick any according to our requirement)
2 . GCD is an C API and on top of it - NSThread and NSOperationQueue,NSOperation are written
3 . NSOperation is nothing but a Thread which has number of tasks within it . Same like main() is Thread . If someone written creating thread which also means creating custom nsoperation
4 . NSConnectionurl,AFNetwork are on top of these GCD,NSThread,NSOperationQueue,NSOperation
Upvotes: 1
Views: 342
Reputation: 151
Please find my inline response below.
1) sync and asyn operations can be done in following ways(we can pick any according to our requirement)
GCD NSThread NSOperationQueue-adding NSOperation
Your understanding is correct, except some modification and adding some more information to NSOperatonQueue.
Even if the implementation of custom operation is synchronous, by adding it to operation queue, converts to asynchronous operation.
And if the custom operation is implemented in synchronous way, calling start method works in a synchronous way - it uses current thread to execute its own task.
2 . GCD is an C API and on top of it - NSThread and NSOperationQueue,NSOperation are written
3 . NSOperation is nothing but a Thread which has number of tasks within it . Same like main() is Thread . If someone written creating thread which also means creating custom nsoperation
The custom operation is either perform tasks in own thread or in a separate thread. It differs with the implementation custom operation.
a) Custom operation implemented in synchronous manner i.e not creating a thread in start method to call the main method. It executes the operation tasks in the current thread the operation start method was called.
But, The same synchronous custom operation, by adding it to operation queue, executes its tasks in separate thread. The separate thread created by operation queue.
b) Custom operation is implemented in asynchronous manner, i.e execute its tasks in separate thread.
4 . NSConnectionurl,AFNetwork are on top of these GCD,NSThread,NSOperationQueue,NSOperation
Upvotes: 1