summaryrefslogtreecommitdiffstats
path: root/core/java/android/annotation/MainThread.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2015-03-10 19:15:27 -0700
committerTor Norbye <tnorbye@google.com>2015-04-20 15:59:17 -0700
commitf8b833605e459265f46cd509beb556cc83d2eeda (patch)
treeb1ab7cd72e05ea6b691c08b691eae216f45fed63 /core/java/android/annotation/MainThread.java
parent6a1c23bf190db7bfc8bba1973c5a03a5af897623 (diff)
downloadframeworks_base-f8b833605e459265f46cd509beb556cc83d2eeda.zip
frameworks_base-f8b833605e459265f46cd509beb556cc83d2eeda.tar.gz
frameworks_base-f8b833605e459265f46cd509beb556cc83d2eeda.tar.bz2
Add threading annotations
These describe threading requirements for a given method, or threading promises made to a callback. Change-Id: If496067b12df3a0adedc32e4b4005cd1c2d400f3
Diffstat (limited to 'core/java/android/annotation/MainThread.java')
-rw-r--r--core/java/android/annotation/MainThread.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/core/java/android/annotation/MainThread.java b/core/java/android/annotation/MainThread.java
new file mode 100644
index 0000000..18a4283
--- /dev/null
+++ b/core/java/android/annotation/MainThread.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+/**
+ * Denotes that the annotated method should only be called on the main thread.
+ * If the annotated element is a class, then all methods in the class should be called
+ * on the main thread.
+ * <p>
+ * Example:
+ * <pre>{@code
+ * &#64;MainThread
+ * public void deliverResult(D data) { ... }
+ * }</pre>
+ *
+ * {@hide}
+ */
+@Retention(SOURCE)
+@Target({METHOD,CONSTRUCTOR,TYPE})
+public @interface MainThread {
+} \ No newline at end of file