Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsemaphore.cpp File Reference
#include "qsemaphore.h"
#include "qfutex_p.h"
#include "qdeadlinetimer.h"
#include "qdatetime.h"
#include "qdebug.h"
#include "qlocking_p.h"
#include "qwaitcondition_p.h"
#include <chrono>
+ Include dependency graph for qsemaphore.cpp:

Go to the source code of this file.

Classes

struct  QtSemaphorePrivate::Layout1
 
struct  QtSemaphorePrivate::Layout2
 
class  QSemaphorePrivate
 

Namespaces

namespace  QtSemaphorePrivate
 

Typedefs

using QtSemaphorePrivate::Members = std::conditional_t< sizeof(Layout1)<=sizeof(Layout2), Layout1, Layout2 >
 

Functions

static int futexAvailCounter (quintptr v)
 
static bool futexNeedsWake (quintptr v)
 
static QBasicAtomicInteger< quint32 > * futexLow32 (QBasicAtomicInteger< quintptr > *ptr)
 
static QBasicAtomicInteger< quint32 > * futexHigh32 (QBasicAtomicInteger< quintptr > *ptr)
 
template<bool IsTimed>
bool futexSemaphoreTryAcquire_loop (QBasicAtomicInteger< quintptr > &u, quintptr curValue, quintptr nn, QDeadlineTimer timer)
 
template<typename T >
bool futexSemaphoreTryAcquire (QBasicAtomicInteger< quintptr > &u, int n, T timeout)
 

Variables

static constexpr bool futexHasWaiterCount = false
 
static constexpr quintptr futexNeedsWakeAllBit
 
static constexpr QDeadlineTimer::ForeverConstant Expired
 

Function Documentation

◆ futexAvailCounter()

static int futexAvailCounter ( quintptr  v)
static

Definition at line 105 of file qsemaphore.cpp.

References futexHasWaiterCount, and Q_ASSERT.

Referenced by QSemaphore::available(), futexSemaphoreTryAcquire(), and futexSemaphoreTryAcquire_loop().

+ Here is the caller graph for this function:

◆ futexHigh32()

static QBasicAtomicInteger< quint32 > * futexHigh32 ( QBasicAtomicInteger< quintptr > *  ptr)
static

Definition at line 137 of file qsemaphore.cpp.

References futexHasWaiterCount, ptr(), and Q_ASSERT.

Referenced by futexSemaphoreTryAcquire(), futexSemaphoreTryAcquire_loop(), and QSemaphore::release().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ futexLow32()

static QBasicAtomicInteger< quint32 > * futexLow32 ( QBasicAtomicInteger< quintptr > *  ptr)
static

Definition at line 128 of file qsemaphore.cpp.

References ptr().

Referenced by futexSemaphoreTryAcquire_loop(), and QSemaphore::release().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ futexNeedsWake()

static bool futexNeedsWake ( quintptr  v)
static

Definition at line 118 of file qsemaphore.cpp.

References futexHasWaiterCount.

Referenced by QSemaphore::release().

+ Here is the caller graph for this function:

◆ futexSemaphoreTryAcquire()

template<typename T >
bool futexSemaphoreTryAcquire ( QBasicAtomicInteger< quintptr > &  u,
int  n,
timeout 
)

Definition at line 195 of file qsemaphore.cpp.

References Expired, QBasicAtomicInteger< T >::fetchAndAddRelaxed(), QBasicAtomicInteger< T >::fetchAndSubRelaxed(), futexAvailCounter(), futexHasWaiterCount, futexHigh32(), QBasicAtomicInteger< T >::loadAcquire(), Q_ASSERT, Q_UINT64_C, qCritical, and QBasicAtomicInteger< T >::testAndSetOrdered().

Referenced by QSemaphore::acquire(), QSemaphore::tryAcquire(), and QSemaphore::tryAcquire().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ futexSemaphoreTryAcquire_loop()

template<bool IsTimed>
bool futexSemaphoreTryAcquire_loop ( QBasicAtomicInteger< quintptr > &  u,
quintptr  curValue,
quintptr  nn,
QDeadlineTimer  timer 
)

Definition at line 148 of file qsemaphore.cpp.

References QBasicAtomicInteger< T >::fetchAndOrRelaxed(), futexAvailCounter(), futexHasWaiterCount, futexHigh32(), futexLow32(), futexNeedsWakeAllBit, QtFreeBSDFutex::futexWait(), QBasicAtomicInteger< T >::loadAcquire(), ptr(), Q_ASSERT, QBasicAtomicInteger< T >::testAndSetOrdered(), and timer.

+ Here is the call graph for this function:

Variable Documentation

◆ Expired

constexpr QDeadlineTimer::ForeverConstant Expired
staticconstexpr
Initial value:
=
ForeverConstant
\value Forever Used when creating a QDeadlineTimer to indicate the deadline should not expire

Definition at line 191 of file qsemaphore.cpp.

Referenced by futexSemaphoreTryAcquire(), and QSemaphore::tryAcquire().

◆ futexHasWaiterCount

constexpr bool futexHasWaiterCount = false
staticconstexpr

◆ futexNeedsWakeAllBit

constexpr quintptr futexNeedsWakeAllBit
staticconstexpr
Initial value:
(Q_UINT64_C(1) << (sizeof(quintptr) * CHAR_BIT - 1)) : 0x80000000U
static constexpr bool futexHasWaiterCount
#define Q_UINT64_C(c)
Definition qtypes.h:53
size_t quintptr
Definition qtypes.h:72

Definition at line 102 of file qsemaphore.cpp.

Referenced by futexSemaphoreTryAcquire_loop(), and QSemaphore::release().