Пример #1
0
 private void putLooseRef(LooseRef ref) {
   RefList<LooseRef> cList, nList;
   do {
     cList = looseRefs.get();
     nList = cList.put(ref);
   } while (!looseRefs.compareAndSet(cList, nList));
   modCnt.incrementAndGet();
   fireRefsChanged();
 }
Пример #2
0
 /**
  * Obtain a modified copy of the cache with a ref stored.
  *
  * <p>This cache instance is not modified by this method.
  *
  * @param ref reference to add or replace.
  * @return a copy of this cache, with the reference added or replaced.
  */
 public RefCache put(Ref ref) {
   RefList<Ref> newIds = this.ids.put(ref);
   RefList<Ref> newSym = this.sym;
   if (ref.isSymbolic()) {
     newSym = newSym.put(ref);
   } else {
     int p = newSym.find(ref.getName());
     if (0 <= p) newSym = newSym.remove(p);
   }
   return new RefCache(newIds, newSym);
 }
Пример #3
0
  void stored(String refName, RefData newData) {
    DhtRef ref = fromData(refName, newData);
    RefCache oldCache, newCache;
    do {
      oldCache = cache.get();
      if (oldCache == null) return;

      RefList<DhtRef> ids = oldCache.ids.put(ref);
      RefList<DhtRef> sym = oldCache.sym;

      if (ref.isSymbolic()) {
        sym = sym.put(ref);
      } else {
        int p = sym.find(refName);
        if (0 <= p) sym = sym.remove(p);
      }

      newCache = new RefCache(ids, sym, oldCache.hints);
    } while (!cache.compareAndSet(oldCache, newCache));
  }