• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.annotations;
18 
19 import static java.lang.annotation.ElementType.FIELD;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 import java.lang.annotation.Target;
24 
25 /**
26  * Specifies a list of locks which are required for read/write operations on a data field.
27  *
28  * <p>
29  * To annotate methods accessing the data field with the annotation {@link CompositeRWLock},
30  * use {@link GuardedBy#value} to annotate method w/ write and/or read access to the data field,
31  * use {@link GuardedBy#anyOf} to annotate method w/ read only access to the data field.
32  * </p>
33  *
34  * <p>
35  * When its {@link #value()} consists of multiple locks:
36  * <ul>
37  *   <li>To write to the protected data, acquire <b>all</b> of the locks
38  *       in the order of the appearance in the {@link #value}.</li>
39  *   <li>To read from the protected data, acquire any of the locks in the {@link #value}.</li>
40  * </ul>
41  * </p>
42  */
43 @Target({FIELD})
44 @Retention(RetentionPolicy.CLASS)
45 public @interface CompositeRWLock {
value()46     String[] value() default {};
47 }
48