From aa18467442011a8ad26ca6396c2bb44f44aba569 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Nov 2018 07:41:45 -0800 Subject: [PATCH] Doc: update docs for the sleeping functions' accuracy And take the opportunity to tell people not to sleep. It's always wrong. Fixes: QTBUG-71757 Change-Id: I36203b7dac414e3eb9effffd1566b956dd05f32a Reviewed-by: Lars Knoll --- src/corelib/thread/qthread.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index d3f60eea4f..05bc064005 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -650,6 +650,13 @@ QThread::Priority QThread::priority() const Forces the current thread to sleep for \a secs seconds. + Avoid using this function if you need to wait for a given condition to + change. Instead, connect a slot to the signal that indicates the change or + use an event handler (see \l QObject::event()). + + \note This function does not guarantee accuracy. The application may sleep + longer than \a secs under heavy load conditions. + \sa msleep(), usleep() */ @@ -658,6 +665,14 @@ QThread::Priority QThread::priority() const Forces the current thread to sleep for \a msecs milliseconds. + Avoid using this function if you need to wait for a given condition to + change. Instead, connect a slot to the signal that indicates the change or + use an event handler (see \l QObject::event()). + + \note This function does not guarantee accuracy. The application may sleep + longer than \a msecs under heavy load conditions. Some OSes might round \a + msecs up to 10 ms or 15 ms. + \sa sleep(), usleep() */ @@ -666,6 +681,15 @@ QThread::Priority QThread::priority() const Forces the current thread to sleep for \a usecs microseconds. + Avoid using this function if you need to wait for a given condition to + change. Instead, connect a slot to the signal that indicates the change or + use an event handler (see \l QObject::event()). + + \note This function does not guarantee accuracy. The application may sleep + longer than \a usecs under heavy load conditions. Some OSes might round \a + usecs up to 10 ms or 15 ms; on Windows, it will be rounded up to a multiple + of 1 ms. + \sa sleep(), msleep() */