本文整理汇总了Java中java.util.concurrent.atomic.AtomicMarkableReference.getReference方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicMarkableReference.getReference方法的具体用法?Java AtomicMarkableReference.getReference怎么用?Java AtomicMarkableReference.getReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.AtomicMarkableReference
的用法示例。
在下文中一共展示了AtomicMarkableReference.getReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Finding
import java.util.concurrent.atomic.AtomicMarkableReference; //导入方法依赖的package包/类
Finding(T value) {
retry: while (true) {
prev = head;
curr = head.reference.getReference();
Node succ;
while (curr != null) {
AtomicMarkableReference<Node> ref = curr.reference;
succ = ref.getReference();
if (ref.isMarked()) { // try to delete physically
if (!prev.reference.compareAndSet(curr, succ, false, false)) {
continue retry;
}
curr = succ;
} else {
if (curr.value.compareTo(value) >= 0) return;
prev = curr;
curr = succ;
}
}
return;
}
}
示例2: find
import java.util.concurrent.atomic.AtomicMarkableReference; //导入方法依赖的package包/类
private Pair<AtomicMarkableReference<Node>, Node> find(T value) {
while (true) {
AtomicMarkableReference<Node> curr = head;
Node next = head.getReference();
while (true) {
if (next == null)
return new Pair<>(curr, null);
if (next.next.isMarked()) {
if (!curr.compareAndSet(next, next.next.getReference(), false, false))
break;
next = next.next.getReference();
} else {
if (curr.getReference().value.compareTo(value) >= 0)
return new Pair<>(curr, next);
curr = next.next;
next = curr.getReference();
}
}
}
}