As for iOS, what is the difference between the Concurrency programming guide and the thread programming guide?

The reason for my question is that I am writing an application for hosting audio devices for the iPhone, and I need to synchronize access to memory from audio streams (write to memory) and from a GUI stream (read from memory).

When searching for reading guides on this subject, I realized that the apple provides two guides for parallel programming in iOS (similar guides are available for OS X):

As for iOS, I'm new to concurrent programming; therefore, it is not clear to me which of the manuals I need to read, or if they cover the same questions.

+4
source share
2 answers

The Concurrency Programming Guide will be your crash course in send APIs (aka GCD) and NSOperation s.

The thread programming guide will introduce you to the APIs and technologies of Threads, Mutual Exclusion and Synchronization. They will also cover thread creation and interaction with Run Loops.

For your stated problem, the information in the thread programming guide will be more helpful.

However, most of what these guides are about is thinking that the lock is in order. Real-time audio, this is not normal.

AudioUnit hosting basics are also required for reading: http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/AudioUnitHostingGuide_iOS/AudioUnitHostingFundamentals/AudioUnitHostingFundamentals.html

If you are animating your user interface, you may need to implement / find a circular buffer implementation.

Beware - real-time concurrency will be a difficult subject if you are new to parallel projects.

+5
source

This is written in a warning window inside the thread programming guide.

Important. If you are developing a new application, you are encouraged to explore alternative OS X technologies for implementing concurrency. This is especially true if you are not already familiar with the design methods required to implement a multi-threaded application. These alternative technologies simplify the work you need to do to implement parallel execution paths and provide much greater performance than traditional threads. For information on these technologies, see the Concurrency Programming Guide.

So, in fact, the difference is that Threading Programming Guide is older and not recommended for use in modern Objective-C.

HOWEVER , as noted in the comments, for operations that require extremely low latency (such as real-time audio editing) are not suitable for NSOperation and GCD .

+4
source

Source: https://habr.com/ru/post/1491615/


All Articles