On 14 Jul 2008, at 10:30 PM, Adam Maxwell wrote:

> On 2008-07-14 12:20:19 -0700, Christiaan Hofman <[EMAIL PROTECTED]>  
> said:
>
>> BTW, I forgot to ask. I don't understand this in the async DO server:
>>
>>         SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
>> 0.1, TRUE);
>>         if (kCFRunLoopRunFinished == result || kCFRunLoopRunStopped
>> == result)
>>             OSAtomicCompareAndSwap32Barrier(0, 1, &serverFlags-
>>> shouldKeepRunning);
>>         else
>>         OSMemoryBarrier();
>>
>> How could shouldKeepRunning ever become 0 in this (except for the
>> server being canceled)? Why doesn't this work:
>>
>>         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
>> untilDate:[NSDate dateWithTimeIntervalSinceDate:0.1]];
>>         OSMemoryBarrier();
>
> This would work as well, but it's not checking a return value.
> Checking the result allows seeing if the calling thread's runloop
> (typically main thread) has stopped and kills the server.  I think the
> idea was to avoid blocking in case the app could be quitting while  
> this
> thing was setting up, or someone could cancel it immediately.
>

Doesn't this do the opposite, as it sets the shouldKeepRunning to 1  
when it's stopped early?

>> Also, is the NSZoneCAlloc for the flags necessary? Shouldn't calloc  
>> be
>> implied by the aligned? We don't do this with extra aligned flags in
>> subclasses.
>
> I used calloc here it explicitly zeroes memory; the alignment is
> unrelated.  Malloc could be used as well (or convert it to Obj-C++ and
> use new :).
>

And why not just memset? What need is there to explicitly allocate?

> Incidentally, all of the alignment attributes can be removed unless
> there's padding (like a uint8_t) in a struct that would push one of  
> the
> flags to a non-word boundary.  The current usage is based on my  
> misread
> of the docs.
>
> -- 
> adam

OK, I trust you. I guess the volatile is still needed though?

Christiaan


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to