Ejemplo n.º 1
0
 /**
  * Returns the current file cache.
  *
  * @param root root directory
  * @return id, or {@code null} if newer file cache exists
  * @throws InterruptedException interruption
  */
 ProjectCache cache(final IOFile root) throws InterruptedException {
   final ProjectCache pc = cache;
   if (pc == null) {
     // no file cache available: create and return new one
     cache = new ProjectCache();
     add(root, cache);
     cache.finish();
   } else {
     // wait until file cache is initialized
     while (!pc.valid()) {
       Thread.yield();
       // file cache was replaced with newer version
       if (pc != cache) throw new InterruptedException();
     }
   }
   // return existing file cache
   return cache;
 }