Skip to content

Commit

Permalink
INTERNAL: use Arraylist instead of ConcurrentLinkedQueue in future
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviarla committed Aug 30, 2024
1 parent c1c5592 commit 0168439
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -2002,7 +2001,7 @@ private <T> SMGetFuture<List<SMGetElement<T>>> smget(
final int count, final boolean reverse, final Transcoder<T> tc) {

final CountDownLatch blatch = new CountDownLatch(smGetList.size());
final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
final Collection<Operation> ops = new ArrayList<>(smGetList.size());
final SMGetResultOldImpl<T> result = new SMGetResultOldImpl<>(offset, count, reverse, smGetList.size() > 1);

// if processedSMGetCount is 0, then all smget is done.
Expand Down Expand Up @@ -2070,7 +2069,7 @@ private <T> SMGetFuture<List<SMGetElement<T>>> smget(
final boolean reverse, final Transcoder<T> tc) {

final CountDownLatch blatch = new CountDownLatch(smGetList.size());
final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
final Collection<Operation> ops = new ArrayList<>(smGetList.size());
final SMGetResultImpl<T> result = new SMGetResultImpl<>(count, unique, reverse);

// if processedSMGetCount is 0, then all smget is done.
Expand Down Expand Up @@ -3434,7 +3433,7 @@ private <T> CollectionGetBulkFuture<Map<String, BTreeGetResult<Long, T>>> btreeG
final boolean reverse, final Transcoder<T> tc) {

final CountDownLatch latch = new CountDownLatch(getBulkList.size());
final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
final Collection<Operation> ops = new ArrayList<>();
final Map<String, List<BTreeElement<Long, CachedData>>> cachedDataMap =
new HashMap<>();
final Map<String, CollectionOperationStatus> opStatusMap =
Expand Down Expand Up @@ -3494,7 +3493,7 @@ public void gotElement(String key, int flags, Object bkey, byte[] eflag, byte[]
final boolean reverse, final Transcoder<T> tc) {

final CountDownLatch latch = new CountDownLatch(getBulkList.size());
final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
final Collection<Operation> ops = new ArrayList<>(getBulkList.size());
final Map<String, List<BTreeElement<ByteArrayBKey, CachedData>>> cachedDataMap =
new HashMap<>();
final Map<String, CollectionOperationStatus> opStatusMap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand All @@ -14,7 +13,7 @@
import net.spy.memcached.ops.OperationState;

public class BroadcastFuture<T> extends OperationFuture<T> {
private final List<Operation> ops;
private final Collection<Operation> ops;

public BroadcastFuture(long timeout , T result, int latchSize) {
super(new CountDownLatch(latchSize), timeout);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.spy.memcached.internal;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand All @@ -18,7 +18,7 @@

public class BulkOperationFuture<T> implements Future<Map<String, T>> {
protected final Map<String, T> failedResult = new HashMap<>();
protected final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
protected final Collection<Operation> ops = new ArrayList<>();
protected final long timeout;
protected final CountDownLatch latch;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.spy.memcached.internal;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand All @@ -18,7 +18,7 @@

public class PipedCollectionFuture<K, V>
extends CollectionFuture<Map<K, V>> {
private final ConcurrentLinkedQueue<Operation> ops = new ConcurrentLinkedQueue<>();
private final Collection<Operation> ops = new ArrayList<>();
private final AtomicReference<CollectionOperationStatus> operationStatus
= new AtomicReference<>(null);

Expand Down

0 comments on commit 0168439

Please sign in to comment.