Commit 2eb6969
committed
Auto merge of rust-lang#51290 - Pslydhh:master, r=alexcrichton
park/park_timeout: prohibit spurious wakeups in next park
<pre><code>
// The implementation currently uses the trivial strategy of a Mutex+Condvar
// with wakeup flag, which does not actually allow spurious wakeups.
</pre></code>
Because does not actually allow spurious wakeups.
so we have let thread.inner.cvar.wait(m) in the loop to prohibit spurious wakeups.
but if notified after we locked, this notification doesn't be consumed, it return, the next park will consume this notification...this is also 'spurious wakeup' case, 'one unpark() wakeups two park()'.
We should improve this situation:
`thread.inner.state.store(EMPTY, SeqCst);`1 file changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
796 | 796 | | |
797 | 797 | | |
798 | 798 | | |
799 | | - | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
800 | 803 | | |
801 | 804 | | |
802 | 805 | | |
| |||
882 | 885 | | |
883 | 886 | | |
884 | 887 | | |
885 | | - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
886 | 892 | | |
887 | 893 | | |
888 | 894 | | |
| |||
0 commit comments