Loading core/java/android/app/QueuedWork.java +23 −11 Original line number Diff line number Diff line Loading @@ -113,6 +113,22 @@ public class QueuedWork { } } /** * Remove all Messages from the Handler with the given code. * * This method intentionally avoids creating the Handler if it doesn't * already exist. */ private static void handlerRemoveMessages(int what) { synchronized (sLock) { if (sHandler == null) { // Nothing to remove return; } getHandler().removeMessages(what); } } /** * Add a finisher-runnable to wait for {@link #queue asynchronously processed work}. * Loading Loading @@ -156,17 +172,13 @@ public class QueuedWork { long startTime = System.currentTimeMillis(); boolean hadMessages = false; Handler handler = getHandler(); synchronized (sLock) { if (handler.hasMessages(QueuedWorkHandler.MSG_RUN)) { // Delayed work will be processed at processPendingWork() below handler.removeMessages(QueuedWorkHandler.MSG_RUN); if (DEBUG) { hadMessages = true; Log.d(LOG_TAG, "waiting"); hadMessages = getHandler().hasMessages(QueuedWorkHandler.MSG_RUN); } handlerRemoveMessages(QueuedWorkHandler.MSG_RUN); if (DEBUG && hadMessages) { Log.d(LOG_TAG, "waiting"); } // We should not delay any work as this might delay the finishers Loading Loading @@ -257,7 +269,7 @@ public class QueuedWork { sWork = new LinkedList<>(); // Remove all msg-s as all work will be processed now getHandler().removeMessages(QueuedWorkHandler.MSG_RUN); handlerRemoveMessages(QueuedWorkHandler.MSG_RUN); } if (work.size() > 0) { Loading Loading
core/java/android/app/QueuedWork.java +23 −11 Original line number Diff line number Diff line Loading @@ -113,6 +113,22 @@ public class QueuedWork { } } /** * Remove all Messages from the Handler with the given code. * * This method intentionally avoids creating the Handler if it doesn't * already exist. */ private static void handlerRemoveMessages(int what) { synchronized (sLock) { if (sHandler == null) { // Nothing to remove return; } getHandler().removeMessages(what); } } /** * Add a finisher-runnable to wait for {@link #queue asynchronously processed work}. * Loading Loading @@ -156,17 +172,13 @@ public class QueuedWork { long startTime = System.currentTimeMillis(); boolean hadMessages = false; Handler handler = getHandler(); synchronized (sLock) { if (handler.hasMessages(QueuedWorkHandler.MSG_RUN)) { // Delayed work will be processed at processPendingWork() below handler.removeMessages(QueuedWorkHandler.MSG_RUN); if (DEBUG) { hadMessages = true; Log.d(LOG_TAG, "waiting"); hadMessages = getHandler().hasMessages(QueuedWorkHandler.MSG_RUN); } handlerRemoveMessages(QueuedWorkHandler.MSG_RUN); if (DEBUG && hadMessages) { Log.d(LOG_TAG, "waiting"); } // We should not delay any work as this might delay the finishers Loading Loading @@ -257,7 +269,7 @@ public class QueuedWork { sWork = new LinkedList<>(); // Remove all msg-s as all work will be processed now getHandler().removeMessages(QueuedWorkHandler.MSG_RUN); handlerRemoveMessages(QueuedWorkHandler.MSG_RUN); } if (work.size() > 0) { Loading