117dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye/* 217dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * Copyright (C) 2016 The Android Open Source Project 317dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * 417dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * Licensed under the Apache License, Version 2.0 (the "License"); 517dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * you may not use this file except in compliance with the License. 617dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * You may obtain a copy of the License at 717dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * 817dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * http://www.apache.org/licenses/LICENSE-2.0 917dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * 1017dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * Unless required by applicable law or agreed to in writing, software 1117dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * distributed under the License is distributed on an "AS IS" BASIS, 1217dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1317dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * See the License for the specific language governing permissions and 1417dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * limitations under the License. 1517dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye */ 1617dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyepackage android.annotation; 1717dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye 1817dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyeimport static java.lang.annotation.ElementType.CONSTRUCTOR; 1917dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyeimport static java.lang.annotation.ElementType.METHOD; 2017dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyeimport static java.lang.annotation.ElementType.TYPE; 2117dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyeimport static java.lang.annotation.RetentionPolicy.SOURCE; 2217dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye 23910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkeyimport java.lang.annotation.Retention; 24910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkeyimport java.lang.annotation.Target; 25910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey 2617dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye/** 27910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * Denotes that the annotated method can be called from any thread (e.g. it is 28910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * "thread safe".) If the annotated element is a class, then all methods in the 29910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * class can be called from any thread. 3017dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * <p> 31910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * The main purpose of this method is to indicate that you believe a method can 32910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * be called from any thread; static tools can then check that nothing you call 33910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * from within this method or class have more strict threading requirements. 3417dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * <p> 3517dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * Example: 36910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * 37910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * <pre> 38910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * <code> 3917dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * @AnyThread 4017dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * public void deliverResult(D data) { ... } 41910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * </code> 42910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * </pre> 4317dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye * 44910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * @memberDoc This method is safe to call from any thread. 45910e081216ac530432ac9d0aab10d5e5e4c73ab8Jeff Sharkey * @hide 4617dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye */ 4717dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye@Retention(SOURCE) 4817dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye@Target({METHOD,CONSTRUCTOR,TYPE}) 4917dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbyepublic @interface AnyThread { 5017dd669fc3b5ff3a3025b9246ac423d1e10b7783Tor Norbye} 51