File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1008,7 +1008,12 @@ impl RawRwLock {
1008
1008
state & READERS_MASK != 0 && state & WRITER_PARKED_BIT != 0
1009
1009
} ;
1010
1010
let before_sleep = || { } ;
1011
- let timed_out = |_, _| { } ;
1011
+ let timed_out = |_, was_last_thread : bool | {
1012
+ // Clear the parked bit while holding the queue lock. There can
1013
+ // only be one thread parked (this one).
1014
+ debug_assert ! ( was_last_thread) ;
1015
+ self . state . fetch_and ( !WRITER_PARKED_BIT , Ordering :: Relaxed ) ;
1016
+ } ;
1012
1017
// SAFETY:
1013
1018
// * `addr` is an address we control.
1014
1019
// * `validate`/`timed_out` does not panic or call into any function of `parking_lot`.
@@ -1037,10 +1042,9 @@ impl RawRwLock {
1037
1042
// We need to release WRITER_BIT and revert back to
1038
1043
// our previous value. We also wake up any threads that
1039
1044
// might be waiting on WRITER_BIT.
1040
- let state = self . state . fetch_add (
1041
- prev_value. wrapping_sub ( WRITER_BIT | WRITER_PARKED_BIT ) ,
1042
- Ordering :: Relaxed ,
1043
- ) ;
1045
+ let state = self
1046
+ . state
1047
+ . fetch_add ( prev_value. wrapping_sub ( WRITER_BIT ) , Ordering :: Relaxed ) ;
1044
1048
if state & PARKED_BIT != 0 {
1045
1049
let callback = |_, result : UnparkResult | {
1046
1050
// Clear the parked bit if there no more parked threads
You can’t perform that action at this time.
0 commit comments