Exemple #1
0
 private static SuperLock getSuperLock(Collection<? extends CleaningNode> caches) {
   List<Lock> locks = new ArrayList<Lock>(caches.size());
   for (CleaningNode cache : caches) {
     Lock lock = cache.getLock();
     if (lock != null) {
       locks.add(lock);
     }
   }
   return new SuperLock(locks);
 }
Exemple #2
0
 public static void lockAndClear(Collection<? extends CleaningNode> elements) {
   Iterable<DependencyNode> nodes = nodeMapping(elements);
   TIdentityHashSet<CleaningNode> elementsAndDependent =
       DependencyTracker.getAllDependentNodes(nodes, elements);
   while (true) {
     SuperLock superLock = getSuperLock(elementsAndDependent);
     superLock.lock();
     try {
       TIdentityHashSet<CleaningNode> newElements =
           DependencyTracker.getAllDependentNodes(nodes, elements);
       if (newElements.equals(elementsAndDependent)) {
         for (CleaningNode element : elementsAndDependent) {
           element.clear();
         }
         return;
       }
       // the set of dependent caches has been altered, lock everything again
       elementsAndDependent = newElements;
     } finally {
       superLock.unlock();
     }
   }
 }
Exemple #3
0
 private static void clear(Collection<? extends CleaningNode> caches) {
   for (CleaningNode cache : caches) {
     cache.clear();
   }
 }