aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-05-10 16:21:59 -0600
committerdaneren2005 <daneren2005@gmail.com>2013-05-10 16:21:59 -0600
commite93e67ba88c901cfd3050256e474af07000b0918 (patch)
treeb61547aca152b336c113c854950270fb205aa8f8 /subsonic-android/src/github/daneren2005
parent7d245799ef712a39cd70aad3791ff3f1bbdbfd04 (diff)
downloaddsub-e93e67ba88c901cfd3050256e474af07000b0918.tar.gz
dsub-e93e67ba88c901cfd3050256e474af07000b0918.tar.bz2
dsub-e93e67ba88c901cfd3050256e474af07000b0918.zip
Don't bother allowing multiple serialize tasks to wait
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index e1df05a8..a31ac657 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantLock;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -56,6 +57,7 @@ public class DownloadServiceLifecycleSupport {
private BroadcastReceiver ejectEventReceiver;
private PhoneStateListener phoneStateListener;
private boolean externalStorageAvailable= true;
+ private ReentrantLock lock = new ReentrantLock();
/**
* This receiver manages the intent that could come from other applications.
@@ -310,8 +312,9 @@ public class DownloadServiceLifecycleSupport {
private class SerializeTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
- synchronized(DownloadServiceLifecycleSupport.this) {
+ if(lock.tryLock()) {
serializeDownloadQueueNow();
+ lock.unlock();
}
return null;
}
@@ -319,9 +322,9 @@ public class DownloadServiceLifecycleSupport {
private class DeserializeTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
- synchronized(DownloadServiceLifecycleSupport.this) {
- deserializeDownloadQueueNow();
- }
+ lock.lock();
+ deserializeDownloadQueueNow();
+ lock.unlock();
return null;
}
}