Skip to content

Commit

Permalink
Concurrent AssocMap to support concurrency with inner collections
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaGalabut committed Dec 1, 2024
1 parent 2270a8c commit 9f56252
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions oap-stdlib/src/main/java/oap/util/ConcurrentAssocMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import com.google.common.base.Preconditions;
import lombok.NoArgsConstructor;

import java.util.*;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Consumer;
Expand All @@ -26,11 +30,11 @@ public abstract class ConcurrentAssocMap<K, V> {

protected abstract K keyOf( V label );

public ConcurrentAssocMap(ConcurrentMap<K, V> entries ) {
public ConcurrentAssocMap( ConcurrentMap<K, V> entries ) {
this.entries = entries;
}

public ConcurrentAssocMap(Collection<V> values ) {
public ConcurrentAssocMap( Collection<V> values ) {
entries = values.stream().collect( Collectors.toConcurrentMap( this::keyOf, Function.identity() ) );
}

Expand Down

0 comments on commit 9f56252

Please sign in to comment.