summaryrefslogtreecommitdiffstats
path: root/annotations
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2015-03-10 19:12:04 -0700
committerTor Norbye <tnorbye@google.com>2015-03-13 08:58:26 -0700
commit774c065affaddf66d4bec1126183435f7c663ab0 (patch)
tree03da16c38984e94a891060d4f67026d128eb0545 /annotations
parent4bac75523256a9ed741c43da103a4df8e56ba82d (diff)
downloadandroid_frameworks_support-774c065affaddf66d4bec1126183435f7c663ab0.tar.gz
android_frameworks_support-774c065affaddf66d4bec1126183435f7c663ab0.tar.bz2
android_frameworks_support-774c065affaddf66d4bec1126183435f7c663ab0.zip
Add threading annotations
These describe threading requirements for a given method, or threading promises made to a callback. Change-Id: I802d2415c5fa60bc687419bc2564762376a5b3ef
Diffstat (limited to 'annotations')
-rw-r--r--annotations/src/android/support/annotation/BinderThread.java40
-rw-r--r--annotations/src/android/support/annotation/MainThread.java40
-rw-r--r--annotations/src/android/support/annotation/UiThread.java41
-rw-r--r--annotations/src/android/support/annotation/WorkerThread.java40
4 files changed, 161 insertions, 0 deletions
diff --git a/annotations/src/android/support/annotation/BinderThread.java b/annotations/src/android/support/annotation/BinderThread.java
new file mode 100644
index 0000000000..4bb67545ae
--- /dev/null
+++ b/annotations/src/android/support/annotation/BinderThread.java
@@ -0,0 +1,40 @@
+/*
+ * 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.support.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.CLASS;
+
+/**
+ * Denotes that the annotated method should only be called on the binder thread.
+ * If the annotated element is a class, then all methods in the class should be called
+ * on the binder thread.
+ * <p>
+ * Example:
+ * <pre>{@code
+ * (&#64;BinderThread
+ * public BeamShareData createBeamShareData() { ... }
+ * }</pre>
+ */
+@Retention(CLASS)
+@Target({METHOD,CONSTRUCTOR,TYPE})
+public @interface BinderThread {
+} \ No newline at end of file
diff --git a/annotations/src/android/support/annotation/MainThread.java b/annotations/src/android/support/annotation/MainThread.java
new file mode 100644
index 0000000000..28aee06482
--- /dev/null
+++ b/annotations/src/android/support/annotation/MainThread.java
@@ -0,0 +1,40 @@
+/*
+ * 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.support.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.CLASS;
+
+/**
+ * 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>
+ */
+@Retention(CLASS)
+@Target({METHOD,CONSTRUCTOR,TYPE})
+public @interface MainThread {
+} \ No newline at end of file
diff --git a/annotations/src/android/support/annotation/UiThread.java b/annotations/src/android/support/annotation/UiThread.java
new file mode 100644
index 0000000000..a603740ceb
--- /dev/null
+++ b/annotations/src/android/support/annotation/UiThread.java
@@ -0,0 +1,41 @@
+/*
+ * 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.support.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.CLASS;
+
+/**
+ * Denotes that the annotated method or constructor should only be called on the UI thread.
+ * If the annotated element is a class, then all methods in the class should be called
+ * on the UI thread.
+ * <p>
+ * Example:
+ * <pre>{@code
+ * &#64;UiThread
+ *
+ * public abstract void setText(&#64;NonNull String text) { ... }
+ * }</pre>
+ */
+@Retention(CLASS)
+@Target({METHOD,CONSTRUCTOR,TYPE})
+public @interface UiThread {
+} \ No newline at end of file
diff --git a/annotations/src/android/support/annotation/WorkerThread.java b/annotations/src/android/support/annotation/WorkerThread.java
new file mode 100644
index 0000000000..31e34b4665
--- /dev/null
+++ b/annotations/src/android/support/annotation/WorkerThread.java
@@ -0,0 +1,40 @@
+/*
+ * 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.support.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.CLASS;
+
+/**
+ * Denotes that the annotated method should only be called on a worker thread.
+ * If the annotated element is a class, then all methods in the class should be called
+ * on a worker thread.
+ * <p>
+ * Example:
+ * <pre>{@code
+ * (&#64;WorkerThread
+ * protected abstract FilterResults performFiltering(CharSequence constraint);
+ * }</pre>
+ */
+@Retention(CLASS)
+@Target({METHOD,CONSTRUCTOR,TYPE})
+public @interface WorkerThread {
+} \ No newline at end of file