Revision: 22144 http://sourceforge.net/p/bibdesk/svn/22144 Author: hofman Date: 2018-03-22 13:02:56 +0000 (Thu, 22 Mar 2018) Log Message: ----------- rename variable and break loop
Modified Paths: -------------- trunk/bibdesk/BDSKNotesSearchIndex.h trunk/bibdesk/BDSKNotesSearchIndex.m Modified: trunk/bibdesk/BDSKNotesSearchIndex.h =================================================================== --- trunk/bibdesk/BDSKNotesSearchIndex.h 2018-03-22 06:30:34 UTC (rev 22143) +++ trunk/bibdesk/BDSKNotesSearchIndex.h 2018-03-22 13:02:56 UTC (rev 22144) @@ -43,7 +43,7 @@ @interface BDSKNotesSearchIndex : NSObject { SKIndexRef skIndex; - volatile int32_t shouldClear; + volatile int32_t shouldKeepRunning; volatile int32_t needsFlushing; BOOL terminated; dispatch_queue_t queue; Modified: trunk/bibdesk/BDSKNotesSearchIndex.m =================================================================== --- trunk/bibdesk/BDSKNotesSearchIndex.m 2018-03-22 06:30:34 UTC (rev 22143) +++ trunk/bibdesk/BDSKNotesSearchIndex.m 2018-03-22 13:02:56 UTC (rev 22144) @@ -59,7 +59,7 @@ { self = [super init]; if (self) { - shouldClear = 0; + shouldKeepRunning = 0; needsFlushing = 0; terminated = NO; @@ -88,12 +88,17 @@ [super dealloc]; } +- (BOOL)shouldKeepRunning{ + OSMemoryBarrier(); + return shouldKeepRunning; +} + - (void)clearQueue { - OSAtomicCompareAndSwap32Barrier(0, 1, &shouldClear); + OSAtomicCompareAndSwap32Barrier(0, 1, &shouldKeepRunning); dispatch_sync(queue, ^{}); if (terminated == NO) - OSAtomicCompareAndSwap32Barrier(1, 0, &shouldClear); + OSAtomicCompareAndSwap32Barrier(1, 0, &shouldKeepRunning); } - (void)terminate @@ -109,9 +114,10 @@ dispatch_async(queue, ^{ for (NSDictionary *item in items) { + if ([self shouldKeepRunning]) break; NSURL *identifierURL = [item objectForKey:@"identifierURL"]; NSArray *fileURLs = [item objectForKey:@"urls"]; - [self indexItemForIdentifierURL:identifierURL fileURLs:fileURLs removeEmpty:YES]; + [self indexItemForIdentifierURL:identifierURL fileURLs:fileURLs removeEmpty:YES]; } }); } @@ -121,8 +127,9 @@ dispatch_async(queue, ^{ for (NSDictionary *item in items) { + if ([self shouldKeepRunning]) break; NSURL *identifierURL = [item objectForKey:@"identifierURL"]; - [self indexItemForIdentifierURL:identifierURL fileURLs:nil removeEmpty:YES]; + [self indexItemForIdentifierURL:identifierURL fileURLs:nil removeEmpty:YES]; } }); } @@ -152,9 +159,10 @@ dispatch_async(queue, ^{ for (NSDictionary *item in items) { + if ([self shouldKeepRunning]) break; NSURL *identifierURL = [item objectForKey:@"identifierURL"]; NSArray *fileURLs = [item objectForKey:@"urls"]; - [self indexItemForIdentifierURL:identifierURL fileURLs:fileURLs removeEmpty:NO]; + [self indexItemForIdentifierURL:identifierURL fileURLs:fileURLs removeEmpty:NO]; } }); } @@ -179,10 +187,6 @@ - (void)indexItemForIdentifierURL:(NSURL *)identifierURL fileURLs:(NSArray *)fileURLs removeEmpty:(BOOL)removeEmpty { - OSMemoryBarrier(); - if (shouldClear) - return; - NSAutoreleasePool *pool = [NSAutoreleasePool new]; @try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit