ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/AtomicLinkedNode.java
Revision: 1.2
Committed: Tue Jun 24 14:34:47 2003 UTC (20 years, 11 months ago) by dl
Branch: MAIN
CVS Tags: JSR166_PRELIMINARY_TEST_RELEASE_2
Changes since 1.1: +4 -2 lines
Log Message:
Added missing javadoc tags; minor reformatting

File Contents

# User Rev Content
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. Use, modify, and
4     * redistribute this code in any way without acknowledgement.
5     */
6    
7     package java.util.concurrent;
8     import java.util.concurrent.atomic.*;
9    
10     /**
11     * A linked list node supporting atomic operations on both item and
12     * next fields, Used by non-blocking linked-list based classes.
13 dl 1.2 * @since 1.5
14     * @author Doug Lea
15 dl 1.1 */
16    
17     final class AtomicLinkedNode {
18     private volatile Object item;
19     private volatile AtomicLinkedNode next;
20    
21 dl 1.2 private static final AtomicReferenceFieldUpdater<AtomicLinkedNode, AtomicLinkedNode> nextUpdater =
22 dl 1.1 new AtomicReferenceFieldUpdater<AtomicLinkedNode, AtomicLinkedNode>(new AtomicLinkedNode[0], new AtomicLinkedNode[0], "next");
23 dl 1.2 private static final AtomicReferenceFieldUpdater<AtomicLinkedNode, Object> itemUpdater
24 dl 1.1 = new AtomicReferenceFieldUpdater<AtomicLinkedNode, Object>(new AtomicLinkedNode[0], new Object[0], "item");
25    
26     AtomicLinkedNode(Object x) { item = x; }
27    
28     AtomicLinkedNode(Object x, AtomicLinkedNode n) { item = x; next = n; }
29    
30     Object getItem() {
31     return item;
32     }
33    
34     boolean casItem(Object cmp, Object val) {
35     return itemUpdater.compareAndSet(this, cmp, val);
36     }
37    
38     void setItem(Object val) {
39     itemUpdater.set(this, val);
40     }
41    
42     AtomicLinkedNode getNext() {
43     return next;
44     }
45    
46     boolean casNext(AtomicLinkedNode cmp, AtomicLinkedNode val) {
47     return nextUpdater.compareAndSet(this, cmp, val);
48     }
49    
50     void setNext(AtomicLinkedNode val) {
51     nextUpdater.set(this, val);
52     }
53    
54     }