sync::mpsc
: reload state after spinning on CAS failure
This commit is contained in:
parent
8c17a3e7cb
commit
7b721ed0cd
2 changed files with 8 additions and 8 deletions
|
@ -167,9 +167,9 @@ impl<T> Channel<T> {
|
||||||
token.array.stamp = tail + 1;
|
token.array.stamp = tail + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Err(t) => {
|
Err(_) => {
|
||||||
tail = t;
|
|
||||||
backoff.spin();
|
backoff.spin();
|
||||||
|
tail = self.load(Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if stamp.wrapping_add(self.one_lap) == tail + 1 {
|
} else if stamp.wrapping_add(self.one_lap) == tail + 1 {
|
||||||
|
@ -251,8 +251,8 @@ impl<T> Channel<T> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Err(h) => {
|
Err(h) => {
|
||||||
head = h;
|
|
||||||
backoff.spin();
|
backoff.spin();
|
||||||
|
head = self.head.load(Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if stamp == head {
|
} else if stamp == head {
|
||||||
|
|
|
@ -246,10 +246,10 @@ impl<T> Channel<T> {
|
||||||
token.list.offset = offset;
|
token.list.offset = offset;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Err(t) => {
|
Err(_) => {
|
||||||
tail = t;
|
|
||||||
block = self.tail.block.load(Ordering::Acquire);
|
|
||||||
backoff.spin();
|
backoff.spin();
|
||||||
|
tail = self.tail.index.load(Ordering::Acquire);
|
||||||
|
block = self.tail.block.load(Ordering::Acquire);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,9 +351,9 @@ impl<T> Channel<T> {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
Err(h) => {
|
Err(h) => {
|
||||||
head = h;
|
|
||||||
block = self.head.block.load(Ordering::Acquire);
|
|
||||||
backoff.spin();
|
backoff.spin();
|
||||||
|
head = self.head.index.load(Ordering::Acquire);
|
||||||
|
block = self.head.block.load(Ordering::Acquire);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue