What does OSAtomicIncrement32 lock on? Does dispatch_async cause atomic calls to be not thread safe for the original variable?
static volatile int32_t count;
...
dispatch_async(dispatch_get_main_queue(), ^{
...
OSAtomicIncrement32(&count);
}
Is volatile redundant, or could some threads read an old value even if count is always atomically incremented?
Edit: the volatile question was cleared up by http://www.drdobbs.com/parallel/volatile-vs-volatile/212701484. That can be found by following several links in the answer, but thought I'd post it here for quick reference. In short, 'volatile' does not mean the same thing in Java as in Objective-C.