Skip navigation.
 
mlRe: Using OSMemoryBarrier() with KVO
FROM : Paul Thomas
DATE : Wed Apr 23 20:32:06 2008

On 23 Apr 2008, at 03:41, Ken Thomases wrote:

> On Apr 22, 2008, at 6:37 AM, Paul Thomas wrote:

>>
>> Is this enough? Or will I need to use a full blown lock?

>
> What is it that you fear going wrong, such that you think even 
> OSMemoryBarrier is necessary?


I think the barrier is needed to ensure that when other threads see 
done == YES, they can be certain that the other members are set and 
will not be changed.

What I didn't show in the code, but is implied, is the threads trying 
to access the result by checking done.

  if( [promise isDone] )
    return [promise result];
  else
    [promise observeValue... etc.

Anyway, I missed a hole. It requires an atomic 'observeIfNotDone' 
which means I need a lock. Premature optimisation and all that...

Thanks for you help (both),
pt.

Related mailsAuthorDate
mlUsing OSMemoryBarrier() with KVO Paul Thomas Apr 22, 13:37
mlRe: Using OSMemoryBarrier() with KVO Shawn Erickson Apr 23, 00:15
mlRe: Using OSMemoryBarrier() with KVO Ken Thomases Apr 23, 04:41
mlRe: Using OSMemoryBarrier() with KVO Paul Thomas Apr 23, 20:32