Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mcxiaoke/android-volley
Browse files Browse the repository at this point in the history
  • Loading branch information
mcxiaoke committed Sep 8, 2015
2 parents a99eae5 + 38979b0 commit 4566f1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Volley is already published to Maven Central.

### for Maven

```
``` xml
<dependency>
<groupId>com.mcxiaoke.volley</groupId>
<artifactId>library</artifactId>
Expand All @@ -23,7 +23,7 @@ Volley is already published to Maven Central.

### for Gradle

```
``` groovy
compile 'com.mcxiaoke.volley:library:1.0.18'
```

Expand All @@ -32,15 +32,15 @@ compile 'com.mcxiaoke.volley:library:1.0.18'

add this to repositories section in build.gradle

```
``` groovy
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
```

add this to dependencies section in build.gradle

```
```groovy
compile 'com.mcxiaoke.volley:library:1.0.18-SNAPSHOT'
```

Expand Down
28 changes: 17 additions & 11 deletions src/main/java/com/android/volley/CacheDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ public void run() {
// Make a blocking call to initialize the cache.
mCache.initialize();

Request<?> request;
while (true) {
// release previous request object to avoid leaking request object when mQueue is drained.
request = null;
try {
// Take a request from the queue.
request = mCacheQueue.take();
} catch (InterruptedException e) {
// We may have been interrupted because it was time to quit.
if (mQuit) {
return;
}
continue;
}
try {
// Get a request from the cache triage queue, blocking until
// at least one is available.
final Request<?> request = mCacheQueue.take();
request.addMarker("cache-queue-take");

// If the request has been canceled, don't bother dispatching it.
Expand Down Expand Up @@ -134,24 +144,20 @@ public void run() {

// Post the intermediate response back to the user and have
// the delivery then forward the request along to the network.
final Request<?> finalRequest = request;
mDelivery.postResponse(request, response, new Runnable() {
@Override
public void run() {
try {
mNetworkQueue.put(request);
mNetworkQueue.put(finalRequest);
} catch (InterruptedException e) {
// Not much we can do about this.
}
}
});
}

} catch (InterruptedException e) {
// We may have been interrupted because it was time to quit.
if (mQuit) {
return;
}
continue;
} catch (Exception e) {
VolleyLog.e(e, "Unhandled exception %s", e.toString());
}
}
}
Expand Down

0 comments on commit 4566f1d

Please sign in to comment.