Exemplo n.º 1
0
 public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
   Object existingValueReference;
   Object existingValue;
   do {
     existingValueReference = map.delegate.putIfAbsent(keyReference, valueReference);
     existingValue = map.dereferenceValue(existingValueReference);
   } while (isExpired(existingValueReference, existingValue));
   return existingValue;
 }
Exemplo n.º 2
0
      public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
        // ensure that the existing value is not collected
        do {
          Object existingValueReference;
          Object existingValue;
          do {
            existingValueReference = map.delegate.get(keyReference);
            existingValue = map.dereferenceValue(existingValueReference);
          } while (isExpired(existingValueReference, existingValue));

          if (existingValueReference == null) {
            return Boolean.valueOf(false); // nothing to replace
          }

          if (map.delegate.replace(keyReference, existingValueReference, valueReference)) {
            return existingValue; // existingValue did not expire since we still have a reference to
            // it
          }
        } while (true);
      }
Exemplo n.º 3
0
 public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
   return map.dereferenceValue(map.delegate.put(keyReference, valueReference));
 }