QThread/Unix: move qt_nanosleep to qthread_unix.cpp
It's the only place that uses it. Pick-to: 6.5 Change-Id: Ieec322d73c1e40ad95c8fffd17465370ac209c2f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
parent
caa21ffc65
commit
cf059ac9ec
@ -373,7 +373,6 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
|
||||
|
||||
// in qelapsedtimer_mac.cpp or qtimestamp_unix.cpp
|
||||
timespec qt_gettime() noexcept;
|
||||
void qt_nanosleep(timespec amount);
|
||||
QByteArray qt_readlink(const char *path);
|
||||
|
||||
/* non-static */
|
||||
|
@ -139,20 +139,6 @@ struct timespec qt_gettime() noexcept
|
||||
return tv;
|
||||
}
|
||||
|
||||
void qt_nanosleep(timespec amount)
|
||||
{
|
||||
// We'd like to use clock_nanosleep.
|
||||
//
|
||||
// But clock_nanosleep is from POSIX.1-2001 and both are *not*
|
||||
// affected by clock changes when using relative sleeps, even for
|
||||
// CLOCK_REALTIME.
|
||||
//
|
||||
// nanosleep is POSIX.1-1993
|
||||
|
||||
int r;
|
||||
EINTR_LOOP(r, nanosleep(&amount, &amount));
|
||||
}
|
||||
|
||||
static qint64 elapsedAndRestart(qint64 sec, qint64 frac,
|
||||
qint64 *nowsec, qint64 *nowfrac)
|
||||
{
|
||||
|
@ -491,6 +491,20 @@ void QThread::yieldCurrentThread()
|
||||
|
||||
#endif // QT_CONFIG(thread)
|
||||
|
||||
static void qt_nanosleep(timespec amount)
|
||||
{
|
||||
// We'd like to use clock_nanosleep.
|
||||
//
|
||||
// But clock_nanosleep is from POSIX.1-2001 and both are *not*
|
||||
// affected by clock changes when using relative sleeps, even for
|
||||
// CLOCK_REALTIME.
|
||||
//
|
||||
// nanosleep is POSIX.1-1993
|
||||
|
||||
int r;
|
||||
EINTR_LOOP(r, nanosleep(&amount, &amount));
|
||||
}
|
||||
|
||||
void QThread::sleep(unsigned long secs)
|
||||
{
|
||||
qt_nanosleep(durationToTimespec(std::chrono::seconds{secs}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user