7#include "qplatformdefs.h"
16#ifndef QT_ALWAYS_USE_FUTEX
17#include "private/qfreelist_p.h"
110 if (
d != dummyLocked() &&
d->possiblyUnlocked.loadRelaxed() &&
tryLock()) {
115 qWarning(
"QMutex: destroying locked mutex");
283QRecursiveMutex::~QRecursiveMutex()
341 if (owner.loadRelaxed() == self) {
343 Q_ASSERT_X(
count != 0,
"QMutex::lock",
"Overflow in recursion counter");
355 owner.storeRelaxed(self);
429 owner.storeRelaxed(
nullptr);
641void QBasicMutex::lockInternal() QT_MUTEX_LOCK_NOEXCEPT
661#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
662bool QBasicMutex::lockInternal(
int timeout) QT_MUTEX_LOCK_NOEXCEPT
674bool QBasicMutex::lockInternal(
QDeadlineTimer deadlineTimer) QT_MUTEX_LOCK_NOEXCEPT
676 if (deadlineTimer.hasExpired())
701 if (deadlineTimer.hasExpired())
706#if !defined(QT_ALWAYS_USE_FUTEX)
707 while (!fastTryLock()) {
712 if (
copy == dummyLocked()) {
713 if (deadlineTimer.hasExpired())
718 if (!d_ptr.testAndSetOrdered(dummyLocked(), newD)) {
728 if (deadlineTimer.hasExpired() && !
d->possiblyUnlocked.loadRelaxed())
741 if (
d != d_ptr.loadAcquire()) {
752 old_waiters =
d->waiters.loadAcquire();
756 if (d_ptr.testAndSetAcquire(
d, dummyLocked())) {
768 }
while (!
d->waiters.testAndSetRelaxed(old_waiters, old_waiters + 1));
770 if (
d != d_ptr.loadAcquire()) {
781 if (
d->wait(deadlineTimer)) {
783 if (
d->possiblyUnlocked.loadRelaxed() &&
d->possiblyUnlocked.testAndSetRelaxed(
true,
false))
795 if (!
d->possiblyUnlocked.testAndSetRelaxed(
false,
true)) {
813void QBasicMutex::unlockInternal() noexcept
820 d_ptr.storeRelease(
nullptr);
824#if !defined(QT_ALWAYS_USE_FUTEX)
834 if (d_ptr.testAndSetRelease(
d, 0)) {
836 if (
d->possiblyUnlocked.loadRelaxed() &&
d->possiblyUnlocked.testAndSetRelaxed(
true,
false))
851#if !defined(QT_ALWAYS_USE_FUTEX)
855 enum { BlockCount = 4, MaxIndex=0xffff };
858Q_CONSTINIT
const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
862 FreeListConstants::MaxIndex - (16 + 128 + 1024)
867Q_CONSTINIT
static FreeList freeList_;
876 int i = freelist()->next();
879 Q_ASSERT(
d->refCount.loadRelaxed() == 0);
880 Q_ASSERT(!
d->possiblyUnlocked.loadRelaxed());
882 d->refCount.storeRelaxed(1);
891 freelist()->release(
id);
900 old_waiters = waiters.loadRelaxed();
901 new_waiters = old_waiters;
902 if (new_waiters < 0) {
905 new_waiters -=
value;
906 }
while (!waiters.testAndSetRelaxed(old_waiters, new_waiters));
912#if defined(QT_ALWAYS_USE_FUTEX)
914#elif defined(Q_OS_DARWIN)
T loadRelaxed() const noexcept
void derefWaiters(int value) noexcept
static QMutexPrivate * allocate()
QAtomicInt possiblyUnlocked
bool tryLock(int timeout=0) noexcept
Attempts to lock the mutex.
void unlock() noexcept
Unlocks the mutex.
void lock() noexcept
Locks the mutex.
static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION
Combined button and popup list for selecting options.
void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
void futexWakeOne(Atomic &futex)
constexpr bool futexAvailable()
void mutexPostUnlock(void *, unsigned)
void mutexPreUnlock(void *, unsigned)
void mutexPreLock(void *, unsigned)
void mutexPostLock(void *, unsigned, int)
static jboolean copy(JNIEnv *, jobject)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QMutexPrivate * dummyFutexValue()
GLenum GLenum GLsizei count
GLbitfield GLuint64 timeout
[4]
#define Q_ASSERT_X(cond, x, msg)