11#include "qplatformdefs.h"
15#include "private/qcore_unix_p.h"
25#if !defined(CLOCK_MONOTONIC)
28#elif defined(_LIBCPP_VERSION) && defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
31#elif defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_CLOCK_MONOTONIC)
34#elif defined(Q_OS_DARWIN)
37#elif defined(Q_OS_QNX)
40#elif defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
44# warning "Unknown C++ Standard Library implementation - code may be sub-optimal"
57 pthread_condattr_t *attrp =
nullptr;
59#if defined(CLOCK_MONOTONIC) && !defined(Q_OS_DARWIN)
60 pthread_condattr_t condattr;
63 pthread_condattr_init(&condattr);
64 auto destroy =
qScopeGuard([&] { pthread_condattr_destroy(&condattr); });
74 using namespace std::chrono;
76 std::conditional_t<SteadyClockClockId == CLOCK_REALTIME, system_clock, steady_clock>;
93 return pthread_cond_timedwait(&
cond, &
mutex, &ti);
105 if (code == 0 &&
wakeups == 0) {
121 if (code && code != ETIMEDOUT)
133 d->waiters =
d->wakeups = 0;
147 d->wakeups =
qMin(
d->wakeups + 1,
d->waiters);
158 d->wakeups =
d->waiters;
167 if (
time == std::numeric_limits<unsigned long>::max())
190 if (
time == std::numeric_limits<unsigned long>::max())
202 if (previousState == Unlocked)
204 if (previousState == RecursivelyLocked) {
205 qWarning(
"QWaitCondition: cannot wait on QReadWriteLocks with recursive lockForWrite()");
212 readWriteLock->unlock();
216 if (previousState == LockedForWrite)
217 readWriteLock->lockForWrite();
219 readWriteLock->lockForRead();
qint64 deadline() const noexcept Q_DECL_PURE_FUNCTION
Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in milli...
constexpr bool isForever() const noexcept
Returns true if this QDeadlineTimer object never expires, false otherwise.
static constexpr ForeverConstant Forever
void unlock() noexcept
Unlocks the mutex.
void lock() noexcept
Locks the mutex.
static QReadWriteLockStates::StateForWaitCondition stateForWaitCondition(const QReadWriteLock *lock)
bool wait(QDeadlineTimer deadline)
int wait_relative(QDeadlineTimer deadline)
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
timespec durationToTimespec(std::chrono::nanoseconds timeout) noexcept
constexpr const T & qMin(const T &a, const T &b)
#define Q_ASSERT_X(cond, x, msg)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
static void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline)
static void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
static void qt_report_pthread_error(int code, const char *where, const char *what)
static QT_BEGIN_NAMESPACE constexpr clockid_t SteadyClockClockId
QDeadlineTimer deadline(30s)