File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -796,7 +796,11 @@ pub fn park() {
796
796
let mut m = thread. inner . lock . lock ( ) . unwrap ( ) ;
797
797
match thread. inner . state . compare_exchange ( EMPTY , PARKED , SeqCst , SeqCst ) {
798
798
Ok ( _) => { }
799
- Err ( NOTIFIED ) => return , // notified after we locked
799
+ Err ( NOTIFIED ) => {
800
+ // should consume this notification, so prohibit spurious wakeups in next park...
801
+ thread. inner . state . store ( EMPTY , SeqCst ) ;
802
+ return ;
803
+ } , // notified after we locked
800
804
Err ( _) => panic ! ( "inconsistent park state" ) ,
801
805
}
802
806
loop {
@@ -882,7 +886,11 @@ pub fn park_timeout(dur: Duration) {
882
886
let m = thread. inner . lock . lock ( ) . unwrap ( ) ;
883
887
match thread. inner . state . compare_exchange ( EMPTY , PARKED , SeqCst , SeqCst ) {
884
888
Ok ( _) => { }
885
- Err ( NOTIFIED ) => return , // notified after we locked
889
+ Err ( NOTIFIED ) => {
890
+ // should consume this notification, so prohibit spurious wakeups in next park...
891
+ thread. inner . state . store ( EMPTY , SeqCst ) ;
892
+ return ;
893
+ } , // notified after we locked
886
894
Err ( _) => panic ! ( "inconsistent park_timeout state" ) ,
887
895
}
888
896
You can’t perform that action at this time.
0 commit comments