Add retry to CondVarBase wait(), make sure Stopwatch is started on construction (Issue #4735)

* ArchMultithreadPosix::waitCondVar() returns every 100ms, so retry until we
  hit timeout.

* Stopwatch constructor should be called with "false" (not "true") to make sure
  Stopwatch is actually running when instantiated.
This commit is contained in:
Nye Liu
2015-09-11 10:42:01 -07:00
committed by Xinyu Hou
parent 1fde0f3e71
commit 8f0530c507
3 changed files with 18 additions and 10 deletions

View File

@@ -513,6 +513,7 @@ XWindowsClipboard::icccmFillCache()
LOG((CLOG_DEBUG1 "selection doesn't support TARGETS"));
data = "";
XWindowsUtil::appendAtomData(data, XA_STRING);
// return; // NTL
}
XWindowsUtil::convertAtomProperty(data);
@@ -1317,7 +1318,7 @@ XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
// by badly behaved selection owners.
XEvent xevent;
std::vector<XEvent> events;
Stopwatch timeout(true);
Stopwatch timeout(false); // timer not stopped, not triggered
static const double s_timeout = 0.25; // FIXME -- is this too short?
bool noWait = false;
while (!m_done && !m_failed) {
@@ -1361,7 +1362,7 @@ XWindowsClipboard::CICCCMGetClipboard::readClipboard(Display* display,
XSelectInput(display, m_requestor, attr.your_event_mask);
// return success or failure
LOG((CLOG_DEBUG1 "request %s", m_failed ? "failed" : "succeeded"));
LOG((CLOG_DEBUG1 "request %s after %fs", m_failed ? "failed" : "succeeded", timeout.getTime()));
return !m_failed;
}