1 |
dl |
1.1 |
/* |
2 |
|
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
|
* Expert Group and released to the public domain, as explained at |
4 |
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
package java.util.concurrent; |
8 |
|
|
|
9 |
|
|
import java.lang.annotation.ElementType; |
10 |
|
|
import java.lang.annotation.Retention; |
11 |
|
|
import java.lang.annotation.RetentionPolicy; |
12 |
|
|
import java.lang.annotation.Target; |
13 |
|
|
|
14 |
|
|
/** |
15 |
|
|
* An annotation expressing that objects and/or their fields are |
16 |
|
|
* expected to encounter memory contention, generally in the form of |
17 |
|
|
* "false sharing". This annotation serves as a hint that such objects |
18 |
|
|
* and fields should reside in locations isolated from those of other |
19 |
|
|
* objects or fields. The effects of this annotation will nearly |
20 |
|
|
* always add space overhead to programs. Its use is warranted only |
21 |
|
|
* when the performance impact of this time/space tradeoff is |
22 |
|
|
* intrinsically worthwhile; for example, in concurrent contexts in |
23 |
|
|
* which each instance of the annotated object is often accessed by a |
24 |
|
|
* different thread. |
25 |
|
|
* |
26 |
|
|
* <p>A {@code @Contended} field annotation may optionally include a |
27 |
|
|
* contention group tag. All fields with the same tag are considered |
28 |
|
|
* as a group with respect to isolation from other groups. A default |
29 |
|
|
* annotation without a tag indicates contention with all other |
30 |
|
|
* fields, including other {@code @Contended} ones. |
31 |
|
|
|
32 |
|
|
* <p>When the annotation is used at the class level, all unannotated |
33 |
|
|
* fields of the object are considered to be in the same default |
34 |
|
|
* group, separate from any fields that carry their own (possibly |
35 |
|
|
* tagged) {@code @Contended} annotations. |
36 |
|
|
* |
37 |
|
|
* <p><b>Sample Usages</b>. (Forthcoming.) |
38 |
|
|
* |
39 |
|
|
* @since 1.8 |
40 |
|
|
*/ |
41 |
|
|
@Retention(RetentionPolicy.RUNTIME) |
42 |
|
|
@Target({ElementType.FIELD, ElementType.TYPE}) |
43 |
|
|
public @interface Contended { |
44 |
|
|
/** |
45 |
|
|
* The (optional) contention group tag. |
46 |
|
|
*/ |
47 |
|
|
String value() default ""; |
48 |
|
|
} |