summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2015-02-26 15:34:16 -0800
committerJeff Brown <jeffbrown@google.com>2015-03-11 15:00:34 -0700
commit3d4e7efe37a4b0dfc5807444e8c3b98a28953377 (patch)
tree12fb6f24cea20afaecae72cac303551f834cae4d /core/java/android/os
parent6c7b41adf9e937a66880b8906389760f3fc82a08 (diff)
downloadframeworks_base-3d4e7efe37a4b0dfc5807444e8c3b98a28953377.zip
frameworks_base-3d4e7efe37a4b0dfc5807444e8c3b98a28953377.tar.gz
frameworks_base-3d4e7efe37a4b0dfc5807444e8c3b98a28953377.tar.bz2
Move sync barrier methods into MessageQueue.
The methods were previously defined on Looper but on reflection they actually make more sense on the MessageQueue instead since the Looper class is primarily concerned with thread lifecycle rather than the actual messages themselves. Change-Id: Iff356b94754fc9960774fa17e3eec9604229cba6
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/Looper.java42
-rw-r--r--core/java/android/os/MessageQueue.java41
2 files changed, 39 insertions, 44 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) {