Hi all,

If one wants to do something with every item in an NSArray in a concurrent way, 
is the following safe/correct?


NSArray* array = @[@5, @6, @7, @8, @9, @10, @11];
        
dispatch_apply([array count], DISPATCH_APPLY_AUTO, ^(size_t idx) {
        id unused = array[idx];
});


Here of course I'm not doing anything interesting, just extracting the object 
from the array.  This is a reduced example.

On one Mac I have, Thread Sanitizer says there is a data race there.  On 
another Mac, Thread Sanitizer does not complain.

My understanding is that this code is correct, and that TSan is wrong to 
complain, but maybe I'm wrong...

Thanks,

Sean
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to