OFMessageQueue should be retaining target and arguments, so it's not going to message a garbage pointer. It could send a message to the search, which would try to forward to its delegate...which will either be nil or valid.
On Jan 20, 2008, at 9:15 AM, Christiaan Hofman wrote: > And what about the OFMessageQueue? > > Christiaan > > On 20 Jan 2008, at 5:31 PM, Adam R. Maxwell wrote: > >> I don't think this is necessary. Pointer assignment is atomic, so >> the >> thread will never see a half-written value. There's no barrier so >> potentially one thread could still "see" the delegate while the other >> sees nil, but the message will always be sent to either the delegate >> or nil. Teardown occurs early enough to obviate that problem >> (intentionally). >> >> On Jan 20, 2008, at 8:20 AM, [EMAIL PROTECTED] wrote: >> >>> Revision: 12596 >>> http://bibdesk.svn.sourceforge.net/bibdesk/? >>> rev=12596&view=rev >>> Author: hofman >>> Date: 2008-01-20 08:20:14 -0800 (Sun, 20 Jan 2008) >>> >>> Log Message: >>> ----------- >>> Don't message delegate on notification thread, as this ivar is not >>> thread safe. >>> >>> Modified Paths: >>> -------------- >>> trunk/bibdesk/BDSKFileSearchIndex.m >>> >>> Modified: trunk/bibdesk/BDSKFileSearchIndex.m >>> =================================================================== >>> --- trunk/bibdesk/BDSKFileSearchIndex.m 2008-01-20 13:51:32 UTC (rev >>> 12595) >>> +++ trunk/bibdesk/BDSKFileSearchIndex.m 2008-01-20 16:20:14 UTC (rev >>> 12596) >>> @@ -58,6 +58,7 @@ >>> - (void)reindexFileURLsIfNeeded:(NSSet *)urlsToReindex >>> forIdentifierURL:(NSURL *)identifierURL; >>> - (void)runIndexThreadForItems:(NSArray *)items; >>> - (void)searchIndexDidUpdate; >>> +- (void)searchIndexDidFinishInitialIndexing; >>> - (void)processNotification:(NSNotification *)note; >>> - (void)handleDocAddItemNotification:(NSNotification *)note; >>> - (void)handleDocDelItemNotification:(NSNotification *)note; >>> @@ -332,7 +333,7 @@ >>> pthread_rwlock_unlock(&rwlock); >>> [indexedIdentifierURLs removeAllObjects]; >>> >>> - [[OFMessageQueue mainQueue] >>> queueSelectorOnce:@selector(searchIndexDidUpdate:) >>> forObject:delegate withObject:self]; >>> + [[OFMessageQueue mainQueue] >>> queueSelectorOnce:@selector(searchIndexDidUpdate) forObject:self >>> withObject:nil]; >>> countSinceLastFlush = flushInterval; >>> } >>> } >>> @@ -357,7 +358,7 @@ >>> } >>> [URLsToRemove release]; >>> >>> - [self searchIndexDidUpdate]; >>> + [self >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate) >>> withObject:nil waitUntilDone:NO]; >>> >>> [items release]; >>> items = itemsToAdd; >>> @@ -375,7 +376,7 @@ >>> >>> OSMemoryBarrier(); >>> if (flags.shouldKeepRunning == 1) >>> - [delegate >>> performSelectorOnMainThread >>> :@selector(searchIndexDidFinishInitialIndexing:) withObject:self >>> waitUntilDone:NO]; >>> + [self >>> performSelectorOnMainThread >>> :@selector(searchIndexDidFinishInitialIndexing) withObject:nil >>> waitUntilDone:NO]; >>> } >>> >>> - (void)indexFileURL:(NSURL *)aURL{ >>> @@ -443,7 +444,7 @@ >>> [pool release]; >>> pool = [NSAutoreleasePool new]; >>> >>> - [self searchIndexDidUpdate]; >>> + [self >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate) >>> withObject:nil waitUntilDone:NO]; >>> countSinceLastFlush = flushInterval; >>> } >>> OSMemoryBarrier(); >>> @@ -454,7 +455,7 @@ >>> // final update to catch any leftovers >>> >>> // it's possible that we've been told to stop, and the delegate >>> is garbage; in that case, don't message it >>> - [self searchIndexDidUpdate]; >>> + [self >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate) >>> withObject:nil waitUntilDone:NO]; >>> [pool release]; >>> } >>> >>> @@ -613,11 +614,20 @@ >>> >>> - (void)searchIndexDidUpdate >>> { >>> + OBASSERT([NSThread inMainThread]); >>> OSMemoryBarrier(); >>> if (flags.shouldKeepRunning == 1) >>> - [delegate >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate:) >>> withObject:self waitUntilDone:NO]; >>> + [delegate searchIndexDidUpdate:self]; >>> } >>> >>> +- (void)searchIndexDidFinishInitialIndexing >>> +{ >>> + OBASSERT([NSThread inMainThread]); >>> + OSMemoryBarrier(); >>> + if (flags.shouldKeepRunning == 1) >>> + [delegate searchIndexDidFinishInitialIndexing:self]; >>> +} >>> + >>> - (void)processNotification:(NSNotification *)note >>> { >>> OBASSERT([NSThread inMainThread]); >>> @@ -660,7 +670,7 @@ >>> } >>> OSAtomicCompareAndSwap32Barrier(1, 0, (int32_t >>> *)&flags.isIndexing); >>> >>> - [self searchIndexDidUpdate]; >>> + [self >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate) >>> withObject:nil waitUntilDone:NO]; >>> } >>> >>> - (void)handleSearchIndexInfoChangedNotification:(NSNotification >>> *)note >>> @@ -710,7 +720,7 @@ >>> [addedURLs release]; >>> [sameURLs release]; >>> >>> - [self searchIndexDidUpdate]; >>> + [self >>> performSelectorOnMainThread:@selector(searchIndexDidUpdate) >>> withObject:nil waitUntilDone:NO]; >>> } >>> >>> - (void)handleMachMessage:(void *)msg >>> >>> >>> This was sent by the SourceForge.net collaborative development >>> platform, the world's largest Open Source development site. >>> >>> --------------------------------------------------------------------- >>> ---- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> Bibdesk-commit mailing list >>> [EMAIL PROTECTED] >>> https://lists.sourceforge.net/lists/listinfo/bibdesk-commit >> >> >> ---------------------------------------------------------------------- >> --- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Bibdesk-develop mailing list >> Bibdesk-develop@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bibdesk-develop > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Bibdesk-develop mailing list > Bibdesk-develop@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/bibdesk-develop ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bibdesk-develop mailing list Bibdesk-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-develop