Skip to content

Commit d945e82

Browse files
committed
Fix assert in RwLock.
1 parent 7baa55b commit d945e82

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/ch9_locks/rwlock_1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<T> RwLock<T> {
2424
let mut s = self.state.load(Relaxed);
2525
loop {
2626
if s < u32::MAX {
27-
assert!(s != u32::MAX - 1, "too many readers");
27+
assert!(s < u32::MAX - 1, "too many readers");
2828
match self.state.compare_exchange_weak(
2929
s, s + 1, Acquire, Relaxed
3030
) {

src/ch9_locks/rwlock_2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<T> RwLock<T> {
2727
let mut s = self.state.load(Relaxed);
2828
loop {
2929
if s < u32::MAX {
30-
assert!(s != u32::MAX - 1, "too many readers");
30+
assert!(s < u32::MAX - 1, "too many readers");
3131
match self.state.compare_exchange_weak(
3232
s, s + 1, Acquire, Relaxed
3333
) {

src/ch9_locks/rwlock_3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<T> RwLock<T> {
3131
let mut s = self.state.load(Relaxed);
3232
loop {
3333
if s % 2 == 0 { // Even.
34-
assert!(s != u32::MAX - 2, "too many readers");
34+
assert!(s < u32::MAX - 2, "too many readers");
3535
match self.state.compare_exchange_weak(
3636
s, s + 2, Acquire, Relaxed
3737
) {

0 commit comments

Comments
 (0)