I am working on a relatively simple iPhone application that has a multi-channel timer with many settings, such as the number of rounds and the round length. We allow certain settings to be made while the timer is running, which means that the timer can read from the same memory as the parameter records. There are no critical sections of code in which several threads are executed simultaneously, but the code from the settings may try to write the memory with which the timer counts.
In terms of a simple example, suppose we are a global variable foo and there is an NSTimer method that looks like this:
- (invalid) timerTick {NSString * x = foo; }
then in the settings code we do this while the timer is running:
foo = @ "test";
Is it enough to make foo atomic in this application, or do we need some sort of locking scheme?
Thanks.
source share