10#include "qplatformdefs.h"
14#include "private/qcore_unix_p.h"
24#if !defined(CLOCK_MONOTONIC)
27#elif defined(_LIBCPP_VERSION) && defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
30#elif defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_CLOCK_MONOTONIC)
33#elif defined(Q_OS_DARWIN)
36#elif defined(Q_OS_QNX)
39#elif defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
43# warning "Unknown C++ Standard Library implementation - code may be sub-optimal"
56 pthread_condattr_t *attrp =
nullptr;
58#if defined(CLOCK_MONOTONIC) && !defined(Q_OS_DARWIN)
59 pthread_condattr_t condattr;
62 pthread_condattr_init(&condattr);
63 auto destroy =
qScopeGuard([&] { pthread_condattr_destroy(&condattr); });
73 using namespace std::chrono;
75 std::conditional_t<SteadyClockClockId == CLOCK_REALTIME, system_clock, steady_clock>;
92 return pthread_cond_timedwait(&
cond, &
mutex, &ti);
104 if (code == 0 &&
wakeups == 0) {
120 if (code && code != ETIMEDOUT)
132 d->waiters =
d->wakeups = 0;
146 d->wakeups =
qMin(
d->wakeups + 1,
d->waiters);
157 d->wakeups =
d->waiters;
166 if (
time == std::numeric_limits<unsigned long>::max())
189 if (
time == std::numeric_limits<unsigned long>::max())
201 if (previousState == Unlocked)
203 if (previousState == RecursivelyLocked) {
204 qWarning(
"QWaitCondition: cannot wait on QReadWriteLocks with recursive lockForWrite()");
211 readWriteLock->unlock();
215 if (previousState == LockedForWrite)
216 readWriteLock->lockForWrite();
218 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)