aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/RequestQueue.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/android/volley/RequestQueue.java')
-rw-r--r--src/main/java/com/android/volley/RequestQueue.java62
1 files changed, 3 insertions, 59 deletions
diff --git a/src/main/java/com/android/volley/RequestQueue.java b/src/main/java/com/android/volley/RequestQueue.java
index 0f2e756..45679a5 100644
--- a/src/main/java/com/android/volley/RequestQueue.java
+++ b/src/main/java/com/android/volley/RequestQueue.java
@@ -20,12 +20,8 @@ import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Queue;
import java.util.Set;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
@@ -49,19 +45,6 @@ public class RequestQueue {
private final AtomicInteger mSequenceGenerator = new AtomicInteger();
/**
- * Staging area for requests that already have a duplicate request in flight.
- *
- * <ul>
- * <li>containsKey(cacheKey) indicates that there is a request in flight for the given cache
- * key.</li>
- * <li>get(cacheKey) returns waiting requests for the given cache key. The in flight request
- * is <em>not</em> contained in that list. Is null if no requests are staged.</li>
- * </ul>
- */
- private final Map<String, Queue<Request<?>>> mWaitingRequests =
- new HashMap<>();
-
- /**
* The set of all requests currently being processed by this RequestQueue. A Request
* will be in this set if it is waiting in any queue or currently being processed by
* any dispatcher.
@@ -240,37 +223,13 @@ public class RequestQueue {
mNetworkQueue.add(request);
return request;
}
-
- // Insert request into stage if there's already a request with the same cache key in flight.
- synchronized (mWaitingRequests) {
- String cacheKey = request.getCacheKey();
- if (mWaitingRequests.containsKey(cacheKey)) {
- // There is already a request in flight. Queue up.
- Queue<Request<?>> stagedRequests = mWaitingRequests.get(cacheKey);
- if (stagedRequests == null) {
- stagedRequests = new LinkedList<>();
- }
- stagedRequests.add(request);
- mWaitingRequests.put(cacheKey, stagedRequests);
- if (VolleyLog.DEBUG) {
- VolleyLog.v("Request for cacheKey=%s is in flight, putting on hold.", cacheKey);
- }
- } else {
- // Insert 'null' queue for this cacheKey, indicating there is now a request in
- // flight.
- mWaitingRequests.put(cacheKey, null);
- mCacheQueue.add(request);
- }
- return request;
- }
- }
+ mCacheQueue.add(request);
+ return request;
+ }
/**
* Called from {@link Request#finish(String)}, indicating that processing of the given request
* has finished.
- *
- * <p>Releases waiting requests for <code>request.getCacheKey()</code> if
- * <code>request.shouldCache()</code>.</p>
*/
<T> void finish(Request<T> request) {
// Remove from the set of requests currently being processed.
@@ -283,21 +242,6 @@ public class RequestQueue {
}
}
- if (request.shouldCache()) {
- synchronized (mWaitingRequests) {
- String cacheKey = request.getCacheKey();
- Queue<Request<?>> waitingRequests = mWaitingRequests.remove(cacheKey);
- if (waitingRequests != null) {
- if (VolleyLog.DEBUG) {
- VolleyLog.v("Releasing %d waiting requests for cacheKey=%s.",
- waitingRequests.size(), cacheKey);
- }
- // Process all queued up requests. They won't be considered as in flight, but
- // that's not a problem as the cache has been primed by 'request'.
- mCacheQueue.addAll(waitingRequests);
- }
- }
- }
}
public <T> void addRequestFinishedListener(RequestFinishedListener<T> listener) {