Skip to content

Commit 52c597e

Browse files
committed
Replace CAX with CAS in HABS.setWord
1 parent e862c44 commit 52c597e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

core/src/main/java/org/neo4j/graphalgo/core/utils/paged/HugeAtomicBitSet.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,17 @@ public void set(long startIndex, long endIndex) {
103103
}
104104

105105
private void setWord(long wordIndex, long bitMask) {
106-
var oldWord = bits.get(wordIndex);
107106
while (true) {
108-
var newWord = oldWord | bitMask;
107+
long oldWord = bits.get(wordIndex);
108+
long newWord = oldWord | bitMask;
109109
if (newWord == oldWord) {
110110
// already set
111111
return;
112112
}
113-
var currentWord = bits.compareAndExchange(wordIndex, oldWord, newWord);
114-
if (currentWord == oldWord) {
115-
// CAX successful
113+
if (bits.compareAndSet(wordIndex, oldWord, newWord)) {;
114+
// CAS successful
116115
return;
117116
}
118-
oldWord = currentWord;
119117
}
120118
}
121119

0 commit comments

Comments
 (0)