Authored by Thomas Rasch

o Add one additional lock due to some problems

@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 #import "RMTileImage.h" 30 #import "RMTileImage.h"
31 #import "RMTile.h" 31 #import "RMTile.h"
32 32
33 -#define kWriteQueueLimit 25 33 +#define kWriteQueueLimit 15
34 34
35 @interface RMDatabaseCache () 35 @interface RMDatabaseCache ()
36 36
@@ -199,7 +199,12 @@ @@ -199,7 +199,12 @@
199 199
200 // Don't add new images to the database while there are still more than kWriteQueueLimit 200 // Don't add new images to the database while there are still more than kWriteQueueLimit
201 // insert operations pending. This prevents some memory issues. 201 // insert operations pending. This prevents some memory issues.
202 - if ([writeQueue operationCount] > kWriteQueueLimit) return; 202 + BOOL skipThisTile = NO;
  203 + [writeQueueLock lock];
  204 + if ([writeQueue operationCount] > kWriteQueueLimit) skipThisTile = YES;
  205 + [writeQueueLock unlock];
  206 +
  207 + if (skipThisTile) return;
203 208
204 [writeQueue addOperationWithBlock:^{ 209 [writeQueue addOperationWithBlock:^{
205 // RMLog(@"addData\t%d", tileHash); 210 // RMLog(@"addData\t%d", tileHash);