Skip to content

Commit

Permalink
Use SeqCst at places
Browse files Browse the repository at this point in the history
... TODO: Describe rationale ...
... TODO: Is that all that's needed? ...

Maybe a solution for #76.
  • Loading branch information
vorner committed Jul 11, 2022
1 parent f7f192d commit 8311400
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/debt/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Node {
//
// Note that the other pointers in the chain never change and are *ordinary* pointers. The
// whole linked list is synchronized through the head.
let mut current = unsafe { LIST_HEAD.load(Acquire).as_ref() };
let mut current = unsafe { LIST_HEAD.load(SeqCst).as_ref() };
while let Some(node) = current {
let result = f(node);
if result.is_some() {
Expand Down Expand Up @@ -143,7 +143,7 @@ impl Node {
.in_use
// We claim a unique control over the generation and the right to write to slots if
// they are NO_DEPT
.compare_exchange(NODE_UNUSED, NODE_USED, Acquire, Relaxed)
.compare_exchange(NODE_UNUSED, NODE_USED, SeqCst, Relaxed)
.is_ok()
{
Some(node)
Expand All @@ -167,7 +167,7 @@ impl Node {
head, node,
// We need to release *the whole chain* here. For that, we need to
// acquire it first.
AcqRel, Relaxed, // Nothing changed, go next round of the loop.
SeqCst, Relaxed, // Nothing changed, go next round of the loop.
) {
head = old;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/hybrid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<T: RefCnt> HybridProtection<T> {
// We already synchronized the start of the sequence by SeqCst in the new_helping vs swap on
// the pointer. We just need to make sure to bring the pointee in (this can be newer than
// what we got in the Debt)
let candidate = storage.load(Acquire);
let candidate = storage.load(SeqCst);

// Try to replace the debt with our candidate. If it works, we get the debt slot to use. If
// not, we get a replacement value, already protected and a debt to take care of.
Expand Down

0 comments on commit 8311400

Please sign in to comment.