- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 
                        - (void)_syncThread:(NSDictionary*)args
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	ERFeedStatusDB *feedStatusDB;
	NSError *error = nil;
	
	[self retain];
	
	// Open FeedStatusDB
	feedStatusDB = [[ERFeedStatusDB alloc] init];
	if (![feedStatusDB openWithPath:[args objectForKey:ERFeedStatusDBSyncFilePathKey] error:&error])
		goto error;
		
	// Perform the sync
	NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init];	// workaround for SQLITE_BUSY issue during -[feedStatusDB close] call
																	// (autoreleased objects are sticking around that keep the DB locked) 
	[self performSyncOnBackgroundThreadWithParams:[args objectForKey:ERFeedStatusDBSyncParamsDictKey] feedStatusDB:feedStatusDB];
	[pool2 release];
	
	[feedStatusDB close];
	[feedStatusDB release];
	feedStatusDB = nil;
	
	[self _setExecuting:NO];
	[_executingCondition lock];
	[_executingCondition signal];
	[_executingCondition unlock];
	
	[self release];
	[pool release];
	return;
	
error:
	[self notifyDelegateOfFailureWithError:error];
	[feedStatusDB close];
	[feedStatusDB release];
	feedStatusDB = nil;
	[self _setExecuting:NO];
	[_executingCondition lock];
	[_executingCondition signal];
	[_executingCondition unlock];
	
	[self release];
	[pool release];
}
                                 
        
            Авторелиз пулы. Goto. [self retain] и [self release]. NSLock. Все это в кастомной реализации NSOperation. 
Код выносит прогулки по базе в бэкграунд. Другого способа, видать, не нашлось.
        
        
Комментарии (0) RSS
Добавить комментарий