fix: atomit wait does not sleep long enough (#5315)
From the documentation of `CondVar::wait_timeout`: > The semantics of this function are equivalent to wait except that the thread > will be blocked for roughly no longer than `dur`. This method should not be > used for precise timing due to anomalies such as preemption or platform > differences that might not cause the maximum amount of time waited to be > precisely `dur`. Therefore, go to sleep again, if the thread has not slept long enough. Signed-off-by: Harald Hoyer <harald@profian.com> Signed-off-by: Harald Hoyer <harald@profian.com>
This commit is contained in:
@@ -115,7 +115,14 @@ impl ParkingSpot {
|
||||
|
||||
let spot = inner.get_mut(&key).expect("failed to get spot");
|
||||
|
||||
if !timed_out {
|
||||
if timed_out {
|
||||
if let Some(timeout) = timeout {
|
||||
if Instant::now() < timeout {
|
||||
// Did not sleep long enough, try again.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if spot.to_unpark == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user