It’s fairly well documented that @synthesize atomic settings/getters are implemented with “something” like so:
{
[_internal lock]; // lock using an object-level lock
id result = [[value retain] autorelease];
[_internal unlock];
return result;
}
The situation I have, I want to access two properties atomically (ie. not unlocking the lock inbetween), so my first instinct was to use @synchronized(self) – however I’ve been unable to find anything that says if @synchronized(self) uses the same lock as an atomic getter/setter. Does anyone know if they do?
One of the things Apple’s docs are very good at, is specifying exactly what the contract is. In this case, the relevant part of the docs says only that it’s locked using an object-level lock. Note that it doesn’t say which lock it is, so you cannot assume it’s the same locking mechanism as
@synchronized(self). (It may very well be not.)