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.
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 mails | Author | Date |
|---|---|---|
| Paul Thomas | Apr 22, 13:37 | |
| Shawn Erickson | Apr 23, 00:15 | |
| Ken Thomases | Apr 23, 04:41 | |
| Paul Thomas | Apr 23, 20:32 |






Cocoa mail archive

