in dispenso/detail/completion_event_impl.h [238:260]
bool waitFor(int completedStatus, const std::chrono::duration<double>& relTime) const {
if (status_.load(std::memory_order_acquire) == completedStatus) {
return true;
}
double relSeconds = relTime.count();
if (relSeconds <= 0.0) {
return false;
}
int msWait = std::max(1, static_cast<int>(relSeconds * 1000.0));
// TODO: determine if we should worry about reducing timeout time subsequent times through the
// loop in the case of spurious wake.
int current;
while ((current = status_.load(std::memory_order_acquire)) != completedStatus) {
if (!WaitOnAddress(&status_, ¤t, sizeof(int), msWait) &&
GetLastError() == ERROR_TIMEOUT) {
return false;
}
}
return true;
}