Esempio 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;
 }
Esempio 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);
      }
Esempio n. 3
0
 public Object execute(ReferenceMap map, Object keyReference, Object valueReference) {
   return map.dereferenceValue(map.delegate.put(keyReference, valueReference));
 }