Is this a non-atomic value?

I have seen @property many times defined as non-atomic for performance reasons. Is there any evidence that it's worth it?

+4
source share
1 answer

If the property is not declared nonatomic , the synthesized accessory will use locks to ensure that the property is thread safe. When a lock is overused, it adds unnecessary messages to your program. The locking operation itself must also be atomic, which means that the processor will lock the memory bus. This can slow down your program, as well as others. If the property is not often available, you probably won't notice the difference, but you definitely want to use it if the property will be used often. In general, however, why not use it? These are a few extra characters that could potentially speed up your program.

+3
source

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


All Articles