diff options
author | Eric Erfanian <erfanian@google.com> | 2017-05-16 00:09:31 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-16 00:09:31 +0000 |
commit | c57430a61eab62e88372f386c75989dab6332608 (patch) | |
tree | b606f1899f80fcd0ea3ee753ce799883d5a673ab /java/com/android/voicemail/impl/scheduling/TaskExecutor.java | |
parent | 9842b4a7fd1d852b1353af806da4913b4298d516 (diff) | |
parent | 0c9dbf507b53a12bdf577ff3e55c1686a2e089de (diff) |
Merge "Update Dialer to v10 RC32" into oc-dev
am: 0c9dbf507b
Change-Id: I5f90090090c6e430d83fcdd294082c1f5237ade8
Diffstat (limited to 'java/com/android/voicemail/impl/scheduling/TaskExecutor.java')
-rw-r--r-- | java/com/android/voicemail/impl/scheduling/TaskExecutor.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java index 84dc1db4a..e3b718e50 100644 --- a/java/com/android/voicemail/impl/scheduling/TaskExecutor.java +++ b/java/com/android/voicemail/impl/scheduling/TaskExecutor.java @@ -193,13 +193,13 @@ final class TaskExecutor { /** Should attempt to run the next task when a task has finished or been added. */ private boolean taskAutoRunDisabledForTesting = false; + /** Handles execution of the background task in teh worker thread. */ @VisibleForTesting final class WorkerThreadHandler extends Handler { public WorkerThreadHandler(Looper looper) { super(looper); } - @Override @WorkerThread public void handleMessage(Message msg) { @@ -218,6 +218,7 @@ final class TaskExecutor { } } + /** Handles completion of the background task in the main thread. */ @VisibleForTesting final class MainThreadHandler extends Handler { @@ -233,6 +234,11 @@ final class TaskExecutor { getTasks().remove(task); task.onCompleted(); isWorkerThreadBusy = false; + if (!isJobRunning() || isTerminating()) { + // TaskExecutor was terminated when the task is running in background, don't need to run the + // next task or terminate again + return; + } maybeRunNextTask(); } } @@ -290,6 +296,7 @@ final class TaskExecutor { @MainThread private void maybeRunNextTask() { Assert.isMainThread(); + if (isWorkerThreadBusy) { return; } |