@@ -183,11 +183,10 @@ struct Node {
183
183
write : bool ,
184
184
thread : OnceCell < Thread > ,
185
185
completed : AtomicBool ,
186
- is_reading : AtomicBool ,
187
186
}
188
187
189
188
impl Node {
190
- /// Creates a new queue node.
189
+ /// Create a new queue node.
191
190
fn new ( write : bool ) -> Node {
192
191
Node {
193
192
next : AtomicLink :: new ( None ) ,
@@ -196,7 +195,6 @@ impl Node {
196
195
write,
197
196
thread : OnceCell :: new ( ) ,
198
197
completed : AtomicBool :: new ( false ) ,
199
- is_reading : AtomicBool :: new ( false ) ,
200
198
}
201
199
}
202
200
@@ -338,17 +336,8 @@ impl RwLock {
338
336
let mut node = Node :: new ( write) ;
339
337
let mut state = self . state . load ( Relaxed ) ;
340
338
let mut count = 0 ;
341
- let mut has_slept = false ;
342
339
loop {
343
- if node. is_reading . load ( Acquire ) {
344
- // This node was awaken by a call to `downgrade`, which means we are already in read
345
- // mode and we can return.
346
- debug_assert ! (
347
- has_slept,
348
- "Somehow `is_reading` is `true` before the node has gone to sleep"
349
- ) ;
350
- return ;
351
- } else if let Some ( next) = update ( state) {
340
+ if let Some ( next) = update ( state) {
352
341
// The lock is available, try locking it.
353
342
match self . state . compare_exchange_weak ( state, next, Acquire , Relaxed ) {
354
343
Ok ( _) => return ,
@@ -418,8 +407,6 @@ impl RwLock {
418
407
node. wait ( ) ;
419
408
}
420
409
421
- has_slept = true ;
422
-
423
410
// The node was removed from the queue, disarm the guard.
424
411
mem:: forget ( guard) ;
425
412
0 commit comments