ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/AtomicLinkedNode.java
Revision: 1.5
Committed: Wed Aug 20 14:49:25 2003 UTC (20 years, 9 months ago) by dl
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
State: FILE REMOVED
Log Message:
AtomicLinkedNode now an inner class of Concurrentlinkedqueue

File Contents

# Content
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 * @since 1.5
14 * @author Doug Lea
15 */
16
17 final class AtomicLinkedNode {
18 private volatile Object item;
19 private volatile AtomicLinkedNode next;
20
21 private static final
22 AtomicReferenceFieldUpdater<AtomicLinkedNode, AtomicLinkedNode>
23 nextUpdater =
24 AtomicReferenceFieldUpdater.newUpdater
25 (AtomicLinkedNode.class, AtomicLinkedNode.class, "next");
26 private static final
27 AtomicReferenceFieldUpdater<AtomicLinkedNode, Object>
28 itemUpdater =
29 AtomicReferenceFieldUpdater.newUpdater
30 (AtomicLinkedNode.class, Object.class, "item");
31
32 AtomicLinkedNode(Object x) { item = x; }
33
34 AtomicLinkedNode(Object x, AtomicLinkedNode n) { item = x; next = n; }
35
36 Object getItem() {
37 return item;
38 }
39
40 boolean casItem(Object cmp, Object val) {
41 return itemUpdater.compareAndSet(this, cmp, val);
42 }
43
44 void setItem(Object val) {
45 itemUpdater.set(this, val);
46 }
47
48 AtomicLinkedNode getNext() {
49 return next;
50 }
51
52 boolean casNext(AtomicLinkedNode cmp, AtomicLinkedNode val) {
53 return nextUpdater.compareAndSet(this, cmp, val);
54 }
55
56 void setNext(AtomicLinkedNode val) {
57 nextUpdater.set(this, val);
58 }
59
60 }