title: Clean GCD queue for all the rest requests in queue
body: <p>I have a cache of files in which I need to write/read images.</p>
  
  <p>All the work with the file system I need to perform in background. </p>
  
  <p>For this purposes for saving files I use:</p>
  
  <pre><code>dispatch_barrier_async([AxPanoramaDataManager sharedInstance].dataManagerQueue, ^{
      [data writeToFile:tileFilePathName atomically:YES];
  });
  </code></pre>
  
  <p>And for reading:</p>
  
  <pre><code>    __block UIImage *tileImage = nil;
      dispatch_sync([AxPanoramaDataManager sharedInstance].dataManagerQueue, ^{
          tileImage = [[UIImage imageWithContentsOfFile:tileFilePathName] retain];
          dispatch_async(dispatch_get_main_queue(), ^{
              completion (tileCoordValue, side, tileImage, error);
              [tileImage release];
          });
      });
  </code></pre>
  
  <p>Everything works well, there is a great amount of files in cash folder, but I sometimes I need to clean the cash. I need to cancel all the queue blocks and perform a block with cleaning the folder. </p>
  
  <p>The first my realization of the method looks like this:</p>
  
  <pre><code>+ (void) cleanCash
  {
      NSString *folderPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingString:@"cash"];
      dispatch_sync([AxPanoramaDataManager sharedInstance].dataManagerQueue, ^{
          NSError *error = nil;
              [[NSFileManager defaultManager] removeItemAtPath:folderPath error:&amp;error];
              NSParameterAssert(error == nil);
          }
      });
  }
  </code></pre>
  
  <p>But I have a numerous problems with it because of it is not cancel the all the waiting operations in queue. I try to look solutions in SO but can't implement them unfortunately. Can anyone help me with this?</p>