Re: dispatch_apply() on an NSArray and Thread Sanitizer

2022-04-19 Thread Sean McBride via Cocoa-dev
On 19 Apr 2022, at 19:35, Rob Petrovec wrote: > The docs for NSEnumerationConcurrent state that it is a hint and may be > ignored at run time. Ah, so they do. I had only checked in the header file. OK, one less mystery. Sean ___ Cocoa-dev mailing l

Re: dispatch_apply() on an NSArray and Thread Sanitizer

2022-04-19 Thread Rob Petrovec via Cocoa-dev
> On Apr 19, 2022, at 5:26 PM, Sean McBride via Cocoa-dev > wrote: > > On 19 Apr 2022, at 18:47, Saagar Jha wrote: > >> If Thread Sanitizer says your code has a race, it almost certainly has a >> race. > > Yeah, that's been my general experience until now. > >> Your simple code seems OK su

Re: dispatch_apply() on an NSArray and Thread Sanitizer

2022-04-19 Thread Sean McBride via Cocoa-dev
On 19 Apr 2022, at 18:47, Saagar Jha wrote: If Thread Sanitizer says your code has a race, it almost certainly has a race. Yeah, that's been my general experience until now. Your simple code seems OK superficially, but there are a couple things that could be problematic here: either your rea

Re: dispatch_apply() on an NSArray and Thread Sanitizer

2022-04-19 Thread Saagar Jha via Cocoa-dev
If Thread Sanitizer says your code has a race, it almost certainly has a race. Your simple code seems OK superficially, but there are a couple things that could be problematic here: either your real code is actually mutating something, or (unlikely) you are touching some internal state, perhaps

dispatch_apply() on an NSArray and Thread Sanitizer

2022-04-19 Thread Sean McBride via Cocoa-dev
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 cour