summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/Looper.java42
-rw-r--r--core/java/android/os/MessageQueue.java41
-rw-r--r--core/java/android/view/ViewRootImpl.java6
3 files changed, 42 insertions, 47 deletions
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index 8b99196..7384dd2 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -243,48 +243,6 @@ public final class Looper {
}
/**
- * Posts a synchronization barrier to the Looper's message queue.
- *
- * Message processing occurs as usual until the message queue encounters the
- * synchronization barrier that has been posted. When the barrier is encountered,
- * later synchronous messages in the queue are stalled (prevented from being executed)
- * until the barrier is released by calling {@link #removeSyncBarrier} and specifying
- * the token that identifies the synchronization barrier.
- *
- * This method is used to immediately postpone execution of all subsequently posted
- * synchronous messages until a condition is met that releases the barrier.
- * Asynchronous messages (see {@link Message#isAsynchronous} are exempt from the barrier
- * and continue to be processed as usual.
- *
- * This call must be always matched by a call to {@link #removeSyncBarrier} with
- * the same token to ensure that the message queue resumes normal operation.
- * Otherwise the application will probably hang!
- *
- * @return A token that uniquely identifies the barrier. This token must be
- * passed to {@link #removeSyncBarrier} to release the barrier.
- *
- * @hide
- */
- public int postSyncBarrier() {
- return mQueue.enqueueSyncBarrier(SystemClock.uptimeMillis());
- }
-
-
- /**
- * Removes a synchronization barrier.
- *
- * @param token The synchronization barrier token that was returned by
- * {@link #postSyncBarrier}.
- *
- * @throws IllegalStateException if the barrier was not found.
- *
- * @hide
- */
- public void removeSyncBarrier(int token) {
- mQueue.removeSyncBarrier(token);
- }
-
- /**
* Return the Thread associated with this Looper.
*/
public Thread getThread() {
diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java
index f4d609c..d672f9b 100644
--- a/core/java/android/os/MessageQueue.java
+++ b/core/java/android/os/MessageQueue.java
@@ -275,7 +275,34 @@ public final class MessageQueue {
}
}
- int enqueueSyncBarrier(long when) {
+ /**
+ * Posts a synchronization barrier to the Looper's message queue.
+ *
+ * Message processing occurs as usual until the message queue encounters the
+ * synchronization barrier that has been posted. When the barrier is encountered,
+ * later synchronous messages in the queue are stalled (prevented from being executed)
+ * until the barrier is released by calling {@link #removeSyncBarrier} and specifying
+ * the token that identifies the synchronization barrier.
+ *
+ * This method is used to immediately postpone execution of all subsequently posted
+ * synchronous messages until a condition is met that releases the barrier.
+ * Asynchronous messages (see {@link Message#isAsynchronous} are exempt from the barrier
+ * and continue to be processed as usual.
+ *
+ * This call must be always matched by a call to {@link #removeSyncBarrier} with
+ * the same token to ensure that the message queue resumes normal operation.
+ * Otherwise the application will probably hang!
+ *
+ * @return A token that uniquely identifies the barrier. This token must be
+ * passed to {@link #removeSyncBarrier} to release the barrier.
+ *
+ * @hide
+ */
+ public int postSyncBarrier() {
+ return postSyncBarrier(SystemClock.uptimeMillis());
+ }
+
+ private int postSyncBarrier(long when) {
// Enqueue a new sync barrier token.
// We don't need to wake the queue because the purpose of a barrier is to stall it.
synchronized (this) {
@@ -304,7 +331,17 @@ public final class MessageQueue {
}
}
- void removeSyncBarrier(int token) {
+ /**
+ * Removes a synchronization barrier.
+ *
+ * @param token The synchronization barrier token that was returned by
+ * {@link #postSyncBarrier}.
+ *
+ * @throws IllegalStateException if the barrier was not found.
+ *
+ * @hide
+ */
+ public void removeSyncBarrier(int token) {
// Remove a sync barrier token from the queue.
// If the queue is no longer stalled by a barrier then wake it.
synchronized (this) {
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 14b867e..7cd12d5 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1049,7 +1049,7 @@ public final class ViewRootImpl implements ViewParent,
void scheduleTraversals() {
if (!mTraversalScheduled) {
mTraversalScheduled = true;
- mTraversalBarrier = mHandler.getLooper().postSyncBarrier();
+ mTraversalBarrier = mHandler.getLooper().getQueue().postSyncBarrier();
mChoreographer.postCallback(
Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
if (!mUnbufferedInputDispatch) {
@@ -1063,7 +1063,7 @@ public final class ViewRootImpl implements ViewParent,
void unscheduleTraversals() {
if (mTraversalScheduled) {
mTraversalScheduled = false;
- mHandler.getLooper().removeSyncBarrier(mTraversalBarrier);
+ mHandler.getLooper().getQueue().removeSyncBarrier(mTraversalBarrier);
mChoreographer.removeCallbacks(
Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
}
@@ -1072,7 +1072,7 @@ public final class ViewRootImpl implements ViewParent,
void doTraversal() {
if (mTraversalScheduled) {
mTraversalScheduled = false;
- mHandler.getLooper().removeSyncBarrier(mTraversalBarrier);
+ mHandler.getLooper().getQueue().removeSyncBarrier(mTraversalBarrier);
if (mProfile) {
Debug.startMethodTracing("ViewAncestor");