mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove ChronicleMap.putMapped() as a duplicate of computeIfPresent(); Reduce the number of ignored tests
This commit is contained in:
@@ -18,7 +18,6 @@ package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.function.SerializableFunction;
|
||||
import net.openhft.chronicle.hash.impl.util.CharSequences;
|
||||
import net.openhft.chronicle.map.impl.IterationContextInterface;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,25 +42,6 @@ interface AbstractChronicleMap<K, V> extends ChronicleMap<K, V>, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default V putMapped(K key, @NotNull UnaryOperator<V> unaryOperator) {
|
||||
requireNonNull(unaryOperator);
|
||||
try (ExternalMapQueryContext<K, V, ?> c = queryContext(key)) {
|
||||
// putMapped() should find a value, update & put most of the time,
|
||||
// so don't try to check key presence under read lock first,
|
||||
// as in putIfAbsent()/acquireUsing(), start with update lock:
|
||||
c.updateLock().lock();
|
||||
MapEntry<K, V> entry = c.entry();
|
||||
if (entry != null) {
|
||||
V newValue = unaryOperator.update(entry.value().get());
|
||||
c.replaceValue(entry, c.wrapValueAsData(newValue));
|
||||
return newValue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default void getAll(File toFile) throws IOException {
|
||||
synchronized (this) {
|
||||
|
||||
Reference in New Issue
Block a user