7#include "qplatformdefs.h"
15#ifndef QT_ALWAYS_USE_FUTEX
16#include "private/qfreelist_p.h"
109 if (
d != dummyLocked() &&
d->possiblyUnlocked.loadRelaxed() &&
tryLock()) {
114 qWarning(
"QMutex: destroying locked mutex");
282QRecursiveMutex::~QRecursiveMutex()
340 if (owner.loadRelaxed() == self) {
342 Q_ASSERT_X(
count != 0,
"QMutex::lock",
"Overflow in recursion counter");
354 owner.storeRelaxed(self);
428 owner.storeRelaxed(
nullptr);
640void QBasicMutex::lockInternal() QT_MUTEX_LOCK_NOEXCEPT
660#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
661bool QBasicMutex::lockInternal(
int timeout) QT_MUTEX_LOCK_NOEXCEPT
673bool QBasicMutex::lockInternal(
QDeadlineTimer deadlineTimer) QT_MUTEX_LOCK_NOEXCEPT
675 if (deadlineTimer.hasExpired())
700 if (deadlineTimer.hasExpired())
705#if !defined(QT_ALWAYS_USE_FUTEX)
706 while (!fastTryLock()) {
711 if (
copy == dummyLocked()) {
712 if (deadlineTimer.hasExpired())
717 if (!d_ptr.testAndSetOrdered(dummyLocked(), newD)) {
727 if (deadlineTimer.hasExpired() && !
d->possiblyUnlocked.loadRelaxed())
740 if (
d != d_ptr.loadAcquire()) {
751 old_waiters =
d->waiters.loadAcquire();
755 if (d_ptr.testAndSetAcquire(
d, dummyLocked())) {
767 }
while (!
d->waiters.testAndSetRelaxed(old_waiters, old_waiters + 1));
769 if (
d != d_ptr.loadAcquire()) {
780 if (
d->wait(deadlineTimer)) {
782 if (
d->possiblyUnlocked.loadRelaxed() &&
d->possiblyUnlocked.testAndSetRelaxed(
true,
false))
794 if (!
d->possiblyUnlocked.testAndSetRelaxed(
false,
true)) {
812void QBasicMutex::unlockInternal() noexcept
819 d_ptr.storeRelease(
nullptr);
823#if !defined(QT_ALWAYS_USE_FUTEX)
833 if (d_ptr.testAndSetRelease(
d, 0)) {
835 if (
d->possiblyUnlocked.loadRelaxed() &&
d->possiblyUnlocked.testAndSetRelaxed(
true,
false))
850#if !defined(QT_ALWAYS_USE_FUTEX)
854 enum { BlockCount = 4, MaxIndex=0xffff };
855 static const int Sizes[BlockCount];
857Q_CONSTINIT
const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {
861 FreeListConstants::MaxIndex - (16 + 128 + 1024)
864typedef QFreeList<QMutexPrivate, FreeListConstants> FreeList;
866Q_CONSTINIT
static FreeList freeList_;
875 int i = freelist()->next();
878 Q_ASSERT(
d->refCount.loadRelaxed() == 0);
879 Q_ASSERT(!
d->possiblyUnlocked.loadRelaxed());
881 d->refCount.storeRelaxed(1);
890 freelist()->release(
id);
899 old_waiters = waiters.loadRelaxed();
900 new_waiters = old_waiters;
901 if (new_waiters < 0) {
904 new_waiters -=
value;
905 }
while (!waiters.testAndSetRelaxed(old_waiters, new_waiters));
911#if defined(QT_ALWAYS_USE_FUTEX)
913#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)