Use of atomic properties in Objective C: Any side effects?

后端 未结 2 1412
借酒劲吻你
借酒劲吻你 2020-12-24 03:35

I understand that the meaning of atomic was explained in What's the difference between the atomic and nonatomic attributes?, but what I want to know is:

2条回答
  •  盖世英雄少女心
    2020-12-24 04:12

    You should not pay for what you do not use. Unlike plugged-in computers where CPU cycles cost you in terms of time, CPU cycles on a mobile device cost you both in time and in the battery use. If your application is single-threaded, there is no reason to use atomic, because the locking and unlocking operations would be a waste of time and battery. The battery is more important than the time: while the latency associated with addition of extra operations may be invisible to your end-user, the cycles spent will reduce the time the mobile device can work after a single charge, a measure that a lot of users consider very important.

提交回复
热议问题