On 2008-07-14 13:49:38 -0700, Christiaan Hofman <[EMAIL PROTECTED]> said:
> > 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? Hmmm....yeah, the parameters are backwards. That code came from FVConcreteOperationQueue, which uses 1 to signal a stop. Copy-and-paste strikes again! >>> 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? Either way should work, but using calloc is just one less call. I'm not sure if memset works properly with all structs, either; ISTR there are problems with floats, for instance. > What need is there to explicitly allocate? Because it's declared in the interface as a pointer to an anonymous/opaque struct. Storage has to be allocated using one of the allocator functions. >> 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? I'm not sure about volatile, but I'd leave it in for the time being. Maybe Mike can explain that one if he gets bored. -- adam ------------------------------------------------------------------------- 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