Authored by Justin R. Miller

remove bottleneck of main queue for background cache callbacks

... ... @@ -85,7 +85,9 @@ typedef enum : short {
#pragma mark -
/** The RMTileCacheBackgroundDelegate protocol is for receiving notifications about background tile cache download operations. */
/** The RMTileCacheBackgroundDelegate protocol is for receiving notifications about background tile cache download operations.
*
* These callbacks are not guaranteed to be received on the main thread, so if you intend to do work in the user interface, you should properly enqueue such jobs on the main thread. */
@protocol RMTileCacheBackgroundDelegate <NSObject>
@optional
... ...
... ... @@ -377,21 +377,21 @@
[operation setCompletionBlock:^(void)
{
dispatch_sync(dispatch_get_main_queue(), ^(void)
if ( ! [internalOperation isCancelled])
{
if ( ! [internalOperation isCancelled])
{
progTile++;
progTile++;
if ([_backgroundCacheDelegate respondsToSelector:@selector(tileCache:didBackgroundCacheTile:withIndex:ofTotalTileCount:)])
{
[_backgroundCacheDelegate tileCache:weakSelf
didBackgroundCacheTile:RMTileMake((uint32_t)x, (uint32_t)y, zoom)
withIndex:progTile
ofTotalTileCount:totalTiles];
}
if ([_backgroundCacheDelegate respondsToSelector:@selector(tileCache:didBackgroundCacheTile:withIndex:ofTotalTileCount:)])
{
[_backgroundCacheDelegate tileCache:weakSelf
didBackgroundCacheTile:RMTileMake((uint32_t)x, (uint32_t)y, zoom)
withIndex:progTile
ofTotalTileCount:totalTiles];
}
if (progTile == totalTiles)
if (progTile == totalTiles)
{
dispatch_async(dispatch_get_main_queue(), ^(void)
{
[weakSelf markCachingComplete];
... ... @@ -399,9 +399,9 @@
{
[_backgroundCacheDelegate tileCacheDidFinishBackgroundCache:weakSelf];
}
}
});
}
});
}
}];
[_backgroundFetchQueue addOperation:operation];
... ...