Clean-up warnings in corelib/thread tests
Fixed the following warnings: - empty expression statement has no effect; remove unnecessary ';' to silence this warning - zero as null pointer constant - no previous extern declaration for non-static variable - use of old-style cast - integer conversion warnings Change-Id: Ieb31b127ce8e3b543aaf88a8e8fc463dcc8bc4e3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
1ec4a7eddc
commit
d75c5026e9
@ -73,7 +73,7 @@ void tst_QAtomicPointer::warningFreeHelper()
|
|||||||
{
|
{
|
||||||
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
|
qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only.");
|
||||||
|
|
||||||
QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0);
|
QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||||
|
|
||||||
p.loadRelaxed()->bar();
|
p.loadRelaxed()->bar();
|
||||||
|
|
||||||
@ -645,8 +645,8 @@ void tst_QAtomicPointer::forwardDeclared()
|
|||||||
// this is just a compilation test
|
// this is just a compilation test
|
||||||
QAtomicPointer<ForwardDeclared> ptr;
|
QAtomicPointer<ForwardDeclared> ptr;
|
||||||
ContainsForwardDeclared cfd;
|
ContainsForwardDeclared cfd;
|
||||||
Q_UNUSED(ptr);
|
Q_UNUSED(ptr)
|
||||||
Q_UNUSED(cfd);
|
Q_UNUSED(cfd)
|
||||||
QVERIFY(true);
|
QVERIFY(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +661,7 @@ template <typename T> static void operators_helper()
|
|||||||
{
|
{
|
||||||
// Test that QBasicAtomicPointer also has operator= and cast operators
|
// Test that QBasicAtomicPointer also has operator= and cast operators
|
||||||
// We've been using them for QAtomicPointer<T> elsewhere
|
// We've been using them for QAtomicPointer<T> elsewhere
|
||||||
QBasicAtomicPointer<T> atomic = Q_BASIC_ATOMIC_INITIALIZER(0);
|
QBasicAtomicPointer<T> atomic = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
|
||||||
atomic = one;
|
atomic = one;
|
||||||
QCOMPARE(Ptr(atomic), one);
|
QCOMPARE(Ptr(atomic), one);
|
||||||
}
|
}
|
||||||
|
@ -1182,13 +1182,13 @@ void tst_QFuture::iterators()
|
|||||||
QVERIFY(c2 != c1);
|
QVERIFY(c2 != c1);
|
||||||
|
|
||||||
int x1 = *i1;
|
int x1 = *i1;
|
||||||
Q_UNUSED(x1);
|
Q_UNUSED(x1)
|
||||||
int x2 = *i2;
|
int x2 = *i2;
|
||||||
Q_UNUSED(x2);
|
Q_UNUSED(x2)
|
||||||
int y1 = *c1;
|
int y1 = *c1;
|
||||||
Q_UNUSED(y1);
|
Q_UNUSED(y1)
|
||||||
int y2 = *c2;
|
int y2 = *c2;
|
||||||
Q_UNUSED(y2);
|
Q_UNUSED(y2)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1240,10 +1240,10 @@ void tst_QFuture::iterators()
|
|||||||
QCOMPARE(x1, y1);
|
QCOMPARE(x1, y1);
|
||||||
QCOMPARE(x2, y2);
|
QCOMPARE(x2, y2);
|
||||||
|
|
||||||
int i1Size = i1->size();
|
auto i1Size = i1->size();
|
||||||
int i2Size = i2->size();
|
auto i2Size = i2->size();
|
||||||
int c1Size = c1->size();
|
auto c1Size = c1->size();
|
||||||
int c2Size = c2->size();
|
auto c2Size = c2->size();
|
||||||
|
|
||||||
QCOMPARE(i1Size, c1Size);
|
QCOMPARE(i1Size, c1Size);
|
||||||
QCOMPARE(i2Size, c2Size);
|
QCOMPARE(i2Size, c2Size);
|
||||||
@ -1688,7 +1688,7 @@ void tst_QFuture::exceptions()
|
|||||||
bool caught = false;
|
bool caught = false;
|
||||||
try {
|
try {
|
||||||
foreach (int e, f.results()) {
|
foreach (int e, f.results()) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e)
|
||||||
QFAIL("did not get exception");
|
QFAIL("did not get exception");
|
||||||
}
|
}
|
||||||
} catch (QException &) {
|
} catch (QException &) {
|
||||||
@ -1755,7 +1755,7 @@ void tst_QFuture::nestedExceptions()
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
MyClass m;
|
MyClass m;
|
||||||
Q_UNUSED(m);
|
Q_UNUSED(m)
|
||||||
throw 0;
|
throw 0;
|
||||||
} catch (int) {}
|
} catch (int) {}
|
||||||
|
|
||||||
@ -1783,7 +1783,7 @@ void tst_QFuture::nonGlobalThreadPool()
|
|||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
const int ms = 100 + (QRandomGenerator::global()->bounded(100) - 100/2);
|
const int ms = 100 + (QRandomGenerator::global()->bounded(100) - 100/2);
|
||||||
QThread::msleep(ms);
|
QThread::msleep(ulong(ms));
|
||||||
reportResult(Answer);
|
reportResult(Answer);
|
||||||
reportFinished();
|
reportFinished();
|
||||||
}
|
}
|
||||||
@ -2913,7 +2913,7 @@ void tst_QFuture::testSingleResult(const std::vector<int> &v)
|
|||||||
template<class T>
|
template<class T>
|
||||||
void tst_QFuture::testSingleResult(const T &unknown)
|
void tst_QFuture::testSingleResult(const T &unknown)
|
||||||
{
|
{
|
||||||
Q_UNUSED(unknown);
|
Q_UNUSED(unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ void mapSleeper(int &)
|
|||||||
QTest::qSleep(100);
|
QTest::qSleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<int> progressValues;
|
static QSet<int> progressValues;
|
||||||
QSet<QString> progressTexts;
|
static QSet<QString> progressTexts;
|
||||||
QMutex mutex;
|
static QMutex mutex;
|
||||||
class ProgressObject : public QObject
|
class ProgressObject : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -191,7 +191,7 @@ class CancelObject : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
bool wasCanceled;
|
bool wasCanceled;
|
||||||
CancelObject() : wasCanceled(false) {};
|
CancelObject() : wasCanceled(false) {}
|
||||||
public slots:
|
public slots:
|
||||||
void cancel();
|
void cancel();
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
Milliseconds,
|
Milliseconds,
|
||||||
Seconds,
|
Seconds,
|
||||||
};
|
};
|
||||||
Q_ENUM(TimeUnit);
|
Q_ENUM(TimeUnit)
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void convertToMilliseconds_data();
|
void convertToMilliseconds_data();
|
||||||
@ -68,11 +68,11 @@ private slots:
|
|||||||
|
|
||||||
static const int iterations = 100;
|
static const int iterations = 100;
|
||||||
|
|
||||||
QAtomicInt lockCount(0);
|
static QAtomicInt lockCount(0);
|
||||||
QMutex normalMutex;
|
static QMutex normalMutex;
|
||||||
QRecursiveMutex recursiveMutex;
|
static QRecursiveMutex recursiveMutex;
|
||||||
QSemaphore testsTurn;
|
static QSemaphore testsTurn;
|
||||||
QSemaphore threadsTurn;
|
static QSemaphore threadsTurn;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Depending on the OS, tryWaits may return early than expected because of the
|
Depending on the OS, tryWaits may return early than expected because of the
|
||||||
@ -1288,14 +1288,14 @@ public:
|
|||||||
quint64 i = 0;
|
quint64 i = 0;
|
||||||
while (t.elapsed() < one_minute) {
|
while (t.elapsed() < one_minute) {
|
||||||
i++;
|
i++;
|
||||||
uint nb = (i * 9 + lockCount.loadRelaxed() * 13) % threadCount;
|
uint nb = (i * 9 + uint(lockCount.loadRelaxed()) * 13) % threadCount;
|
||||||
QMutexLocker locker(&mutex[nb]);
|
QMutexLocker locker(&mutex[nb]);
|
||||||
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
||||||
if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref();
|
if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref();
|
||||||
if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref();
|
if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref();
|
||||||
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
||||||
lockCount.ref();
|
lockCount.ref();
|
||||||
nb = (nb * 17 + i * 5 + lockCount.loadRelaxed() * 3) % threadCount;
|
nb = (nb * 17 + i * 5 + uint(lockCount.loadRelaxed()) * 3) % threadCount;
|
||||||
if (mutex[nb].tryLock()) {
|
if (mutex[nb].tryLock()) {
|
||||||
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
||||||
if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref();
|
if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref();
|
||||||
@ -1304,7 +1304,7 @@ public:
|
|||||||
lockCount.ref();
|
lockCount.ref();
|
||||||
mutex[nb].unlock();
|
mutex[nb].unlock();
|
||||||
}
|
}
|
||||||
nb = (nb * 15 + i * 47 + lockCount.loadRelaxed() * 31) % threadCount;
|
nb = (nb * 15 + i * 47 + uint(lockCount.loadRelaxed()) * 31) % threadCount;
|
||||||
if (mutex[nb].tryLock(2)) {
|
if (mutex[nb].tryLock(2)) {
|
||||||
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
if (sentinel[nb].loadRelaxed()) errorCount.ref();
|
||||||
if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref();
|
if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref();
|
||||||
|
@ -110,7 +110,7 @@ void tst_QMutexLocker::scopeTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ void tst_QMutexLocker::unlockAndRelockTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QMutexLocker::lockerStateTest()
|
void tst_QMutexLocker::lockerStateTest()
|
||||||
@ -197,7 +197,7 @@ void tst_QMutexLocker::lockerStateTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QMutexLocker)
|
QTEST_MAIN(tst_QMutexLocker)
|
||||||
|
@ -77,7 +77,7 @@ private slots:
|
|||||||
|
|
||||||
struct TrivialType { int field = 0; };
|
struct TrivialType { int field = 0; };
|
||||||
struct CopyOnlyType {
|
struct CopyOnlyType {
|
||||||
Q_DISABLE_MOVE(CopyOnlyType);
|
Q_DISABLE_MOVE(CopyOnlyType)
|
||||||
CopyOnlyType() = default;
|
CopyOnlyType() = default;
|
||||||
CopyOnlyType(const CopyOnlyType &) = default;
|
CopyOnlyType(const CopyOnlyType &) = default;
|
||||||
CopyOnlyType& operator=(const CopyOnlyType &) = default;
|
CopyOnlyType& operator=(const CopyOnlyType &) = default;
|
||||||
@ -86,7 +86,7 @@ struct CopyOnlyType {
|
|||||||
int field = 0;
|
int field = 0;
|
||||||
};
|
};
|
||||||
struct MoveOnlyType {
|
struct MoveOnlyType {
|
||||||
Q_DISABLE_COPY(MoveOnlyType);
|
Q_DISABLE_COPY(MoveOnlyType)
|
||||||
MoveOnlyType() = default;
|
MoveOnlyType() = default;
|
||||||
MoveOnlyType(MoveOnlyType &&) = default;
|
MoveOnlyType(MoveOnlyType &&) = default;
|
||||||
MoveOnlyType& operator=(MoveOnlyType &&) = default;
|
MoveOnlyType& operator=(MoveOnlyType &&) = default;
|
||||||
|
@ -109,7 +109,7 @@ void tst_QReadLocker::scopeTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ void tst_QReadLocker::unlockAndRelockTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QReadLocker::lockerStateTest()
|
void tst_QReadLocker::lockerStateTest()
|
||||||
@ -196,7 +196,7 @@ void tst_QReadLocker::lockerStateTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QReadLocker)
|
QTEST_MAIN(tst_QReadLocker)
|
||||||
|
@ -184,10 +184,10 @@ void tst_QReadWriteLock::readWriteLockUnlockLoop()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QAtomicInt lockCount(0);
|
static QAtomicInt lockCount(0);
|
||||||
QReadWriteLock readWriteLock;
|
static QReadWriteLock readWriteLock;
|
||||||
QSemaphore testsTurn;
|
static QSemaphore testsTurn;
|
||||||
QSemaphore threadsTurn;
|
static QSemaphore threadsTurn;
|
||||||
|
|
||||||
|
|
||||||
void tst_QReadWriteLock::tryReadLock()
|
void tst_QReadWriteLock::tryReadLock()
|
||||||
@ -403,8 +403,8 @@ void tst_QReadWriteLock::tryWriteLock()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool threadDone;
|
static bool threadDone;
|
||||||
QAtomicInt release;
|
static QAtomicInt release;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
write-lock
|
write-lock
|
||||||
@ -511,9 +511,9 @@ public:
|
|||||||
while (t.elapsed()<runTime) {
|
while (t.elapsed()<runTime) {
|
||||||
testRwlock.lockForRead();
|
testRwlock.lockForRead();
|
||||||
if(print) printf("reading\n");
|
if(print) printf("reading\n");
|
||||||
if (holdTime) msleep(holdTime);
|
if (holdTime) msleep(ulong(holdTime));
|
||||||
testRwlock.unlock();
|
testRwlock.unlock();
|
||||||
if (waitTime) msleep(waitTime);
|
if (waitTime) msleep(ulong(waitTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -547,14 +547,14 @@ public:
|
|||||||
while (t.elapsed() < runTime) {
|
while (t.elapsed() < runTime) {
|
||||||
testRwlock.lockForWrite();
|
testRwlock.lockForWrite();
|
||||||
if (print) printf(".");
|
if (print) printf(".");
|
||||||
if (holdTime) msleep(holdTime);
|
if (holdTime) msleep(ulong(holdTime));
|
||||||
testRwlock.unlock();
|
testRwlock.unlock();
|
||||||
if (waitTime) msleep(waitTime);
|
if (waitTime) msleep(ulong(waitTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile int count=0;
|
static volatile int count = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(runTime msecs)
|
for(runTime msecs)
|
||||||
@ -594,7 +594,7 @@ public:
|
|||||||
}
|
}
|
||||||
count=0;
|
count=0;
|
||||||
testRwlock.unlock();
|
testRwlock.unlock();
|
||||||
msleep(waitTime);
|
msleep(ulong(waitTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -626,7 +626,7 @@ public:
|
|||||||
if(count)
|
if(count)
|
||||||
qFatal("Non-zero count at Read! (%d)",count );
|
qFatal("Non-zero count at Read! (%d)",count );
|
||||||
testRwlock.unlock();
|
testRwlock.unlock();
|
||||||
msleep(waitTime);
|
msleep(ulong(waitTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -535,7 +535,7 @@ void tst_QtConcurrentResultStore::pendingResultsDoNotLeak_data()
|
|||||||
void tst_QtConcurrentResultStore::pendingResultsDoNotLeak()
|
void tst_QtConcurrentResultStore::pendingResultsDoNotLeak()
|
||||||
{
|
{
|
||||||
QFETCH(bool, filterMode);
|
QFETCH(bool, filterMode);
|
||||||
CountedObject::LeakChecker leakChecker; Q_UNUSED(leakChecker);
|
CountedObject::LeakChecker leakChecker; Q_UNUSED(leakChecker)
|
||||||
|
|
||||||
ResultStoreCountedObject store;
|
ResultStoreCountedObject store;
|
||||||
store.setFilterMode(filterMode);
|
store.setFilterMode(filterMode);
|
||||||
|
@ -106,7 +106,7 @@ void tst_QSemaphore::acquire()
|
|||||||
QVERIFY(t2.wait(4000));
|
QVERIFY(t2.wait(4000));
|
||||||
|
|
||||||
delete semaphore;
|
delete semaphore;
|
||||||
semaphore = 0;
|
semaphore = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// old incrementN() test
|
// old incrementN() test
|
||||||
@ -126,7 +126,7 @@ void tst_QSemaphore::acquire()
|
|||||||
QVERIFY(t2.wait(4000));
|
QVERIFY(t2.wait(4000));
|
||||||
|
|
||||||
delete semaphore;
|
delete semaphore;
|
||||||
semaphore = 0;
|
semaphore = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSemaphore semaphore;
|
QSemaphore semaphore;
|
||||||
@ -177,7 +177,7 @@ void tst_QSemaphore::multiRelease()
|
|||||||
// wait for all threads to reach the sem.acquire() and then
|
// wait for all threads to reach the sem.acquire() and then
|
||||||
// release them all
|
// release them all
|
||||||
QTest::qSleep(1);
|
QTest::qSleep(1);
|
||||||
sem.release(threads.size());
|
sem.release(int(threads.size()));
|
||||||
|
|
||||||
for (Thread *&t : threads)
|
for (Thread *&t : threads)
|
||||||
t->wait();
|
t->wait();
|
||||||
@ -323,69 +323,69 @@ void tst_QSemaphore::tryAcquireWithTimeout()
|
|||||||
QCOMPARE(semaphore.available(), 1);
|
QCOMPARE(semaphore.available(), 1);
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(2, timeout));
|
QVERIFY(!semaphore.tryAcquire(2, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 1);
|
QCOMPARE(semaphore.available(), 1);
|
||||||
|
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
QCOMPARE(semaphore.available(), 2);
|
QCOMPARE(semaphore.available(), 2);
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(3, timeout));
|
QVERIFY(!semaphore.tryAcquire(3, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 2);
|
QCOMPARE(semaphore.available(), 2);
|
||||||
|
|
||||||
semaphore.release(10);
|
semaphore.release(10);
|
||||||
QCOMPARE(semaphore.available(), 12);
|
QCOMPARE(semaphore.available(), 12);
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(100, timeout));
|
QVERIFY(!semaphore.tryAcquire(100, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 12);
|
QCOMPARE(semaphore.available(), 12);
|
||||||
|
|
||||||
semaphore.release(10);
|
semaphore.release(10);
|
||||||
QCOMPARE(semaphore.available(), 22);
|
QCOMPARE(semaphore.available(), 22);
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(100, timeout));
|
QVERIFY(!semaphore.tryAcquire(100, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 22);
|
QCOMPARE(semaphore.available(), 22);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(semaphore.tryAcquire(1, timeout));
|
QVERIFY(semaphore.tryAcquire(1, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), 0);
|
FUZZYCOMPARE(int(time.elapsed()), 0);
|
||||||
QCOMPARE(semaphore.available(), 21);
|
QCOMPARE(semaphore.available(), 21);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(semaphore.tryAcquire(1, timeout));
|
QVERIFY(semaphore.tryAcquire(1, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), 0);
|
FUZZYCOMPARE(int(time.elapsed()), 0);
|
||||||
QCOMPARE(semaphore.available(), 20);
|
QCOMPARE(semaphore.available(), 20);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(semaphore.tryAcquire(10, timeout));
|
QVERIFY(semaphore.tryAcquire(10, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), 0);
|
FUZZYCOMPARE(int(time.elapsed()), 0);
|
||||||
QCOMPARE(semaphore.available(), 10);
|
QCOMPARE(semaphore.available(), 10);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(semaphore.tryAcquire(10, timeout));
|
QVERIFY(semaphore.tryAcquire(10, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), 0);
|
FUZZYCOMPARE(int(time.elapsed()), 0);
|
||||||
QCOMPARE(semaphore.available(), 0);
|
QCOMPARE(semaphore.available(), 0);
|
||||||
|
|
||||||
// should not be able to acquire more
|
// should not be able to acquire more
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(1, timeout));
|
QVERIFY(!semaphore.tryAcquire(1, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 0);
|
QCOMPARE(semaphore.available(), 0);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(1, timeout));
|
QVERIFY(!semaphore.tryAcquire(1, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 0);
|
QCOMPARE(semaphore.available(), 0);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(10, timeout));
|
QVERIFY(!semaphore.tryAcquire(10, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 0);
|
QCOMPARE(semaphore.available(), 0);
|
||||||
|
|
||||||
time.start();
|
time.start();
|
||||||
QVERIFY(!semaphore.tryAcquire(10, timeout));
|
QVERIFY(!semaphore.tryAcquire(10, timeout));
|
||||||
FUZZYCOMPARE(time.elapsed(), timeout);
|
FUZZYCOMPARE(int(time.elapsed()), timeout);
|
||||||
QCOMPARE(semaphore.available(), 0);
|
QCOMPARE(semaphore.available(), 0);
|
||||||
|
|
||||||
#undef FUZZYCOMPARE
|
#undef FUZZYCOMPARE
|
||||||
@ -481,7 +481,7 @@ const char alphabet[] = "ACGTH";
|
|||||||
const int AlphabetSize = sizeof(alphabet) - 1;
|
const int AlphabetSize = sizeof(alphabet) - 1;
|
||||||
|
|
||||||
const int BufferSize = 4096; // GCD of BufferSize and alphabet size must be 1
|
const int BufferSize = 4096; // GCD of BufferSize and alphabet size must be 1
|
||||||
char buffer[BufferSize];
|
static char buffer[BufferSize];
|
||||||
|
|
||||||
const int ProducerChunkSize = 3;
|
const int ProducerChunkSize = 3;
|
||||||
const int ConsumerChunkSize = 7;
|
const int ConsumerChunkSize = 7;
|
||||||
@ -491,8 +491,8 @@ const int Multiplier = 10;
|
|||||||
// ProducerChunkSize, ConsumerChunkSize, and BufferSize
|
// ProducerChunkSize, ConsumerChunkSize, and BufferSize
|
||||||
const int DataSize = ProducerChunkSize * ConsumerChunkSize * BufferSize * Multiplier;
|
const int DataSize = ProducerChunkSize * ConsumerChunkSize * BufferSize * Multiplier;
|
||||||
|
|
||||||
QSemaphore freeSpace(BufferSize);
|
static QSemaphore freeSpace(BufferSize);
|
||||||
QSemaphore usedSpace;
|
static QSemaphore usedSpace;
|
||||||
|
|
||||||
class Producer : public QThread
|
class Producer : public QThread
|
||||||
{
|
{
|
||||||
|
@ -241,9 +241,9 @@ public:
|
|||||||
enum SleepType { Second, Millisecond, Microsecond };
|
enum SleepType { Second, Millisecond, Microsecond };
|
||||||
|
|
||||||
SleepType sleepType;
|
SleepType sleepType;
|
||||||
int interval;
|
ulong interval;
|
||||||
|
|
||||||
int elapsed; // result, in *MILLISECONDS*
|
qint64 elapsed; // result, in *MILLISECONDS*
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
@ -272,25 +272,25 @@ public:
|
|||||||
void tst_QThread::currentThreadId()
|
void tst_QThread::currentThreadId()
|
||||||
{
|
{
|
||||||
Current_Thread thread;
|
Current_Thread thread;
|
||||||
thread.id = 0;
|
thread.id = nullptr;
|
||||||
thread.thread = 0;
|
thread.thread = nullptr;
|
||||||
thread.start();
|
thread.start();
|
||||||
QVERIFY(thread.wait(five_minutes));
|
QVERIFY(thread.wait(five_minutes));
|
||||||
QVERIFY(thread.id != 0);
|
QVERIFY(thread.id != nullptr);
|
||||||
QVERIFY(thread.id != QThread::currentThreadId());
|
QVERIFY(thread.id != QThread::currentThreadId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QThread::currentThread()
|
void tst_QThread::currentThread()
|
||||||
{
|
{
|
||||||
QVERIFY(QThread::currentThread() != 0);
|
QVERIFY(QThread::currentThread() != nullptr);
|
||||||
QCOMPARE(QThread::currentThread(), thread());
|
QCOMPARE(QThread::currentThread(), thread());
|
||||||
|
|
||||||
Current_Thread thread;
|
Current_Thread thread;
|
||||||
thread.id = 0;
|
thread.id = nullptr;
|
||||||
thread.thread = 0;
|
thread.thread = nullptr;
|
||||||
thread.start();
|
thread.start();
|
||||||
QVERIFY(thread.wait(five_minutes));
|
QVERIFY(thread.wait(five_minutes));
|
||||||
QCOMPARE(thread.thread, (QThread *)&thread);
|
QCOMPARE(thread.thread, static_cast<QThread *>(&thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QThread::idealThreadCount()
|
void tst_QThread::idealThreadCount()
|
||||||
@ -646,7 +646,7 @@ void noop(void*) { }
|
|||||||
class NativeThreadWrapper
|
class NativeThreadWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NativeThreadWrapper() : qthread(0), waitForStop(false) {}
|
NativeThreadWrapper() : qthread(nullptr), waitForStop(false) {}
|
||||||
void start(FunctionPointer functionPointer = noop, void *data = nullptr);
|
void start(FunctionPointer functionPointer = noop, void *data = nullptr);
|
||||||
void startAndWait(FunctionPointer functionPointer = noop, void *data = nullptr);
|
void startAndWait(FunctionPointer functionPointer = noop, void *data = nullptr);
|
||||||
void join();
|
void join();
|
||||||
@ -672,8 +672,8 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data)
|
|||||||
this->functionPointer = functionPointer;
|
this->functionPointer = functionPointer;
|
||||||
this->data = data;
|
this->data = data;
|
||||||
#if defined Q_OS_UNIX
|
#if defined Q_OS_UNIX
|
||||||
const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this);
|
const int state = pthread_create(&nativeThreadHandle, nullptr, NativeThreadWrapper::runUnix, this);
|
||||||
Q_UNUSED(state);
|
Q_UNUSED(state)
|
||||||
#elif defined Q_OS_WIN
|
#elif defined Q_OS_WIN
|
||||||
unsigned thrdid = 0;
|
unsigned thrdid = 0;
|
||||||
nativeThreadHandle = (Qt::HANDLE) _beginthreadex(NULL, 0, NativeThreadWrapper::runWin, this, 0, &thrdid);
|
nativeThreadHandle = (Qt::HANDLE) _beginthreadex(NULL, 0, NativeThreadWrapper::runWin, this, 0, &thrdid);
|
||||||
@ -690,7 +690,7 @@ void NativeThreadWrapper::startAndWait(FunctionPointer functionPointer, void *da
|
|||||||
void NativeThreadWrapper::join()
|
void NativeThreadWrapper::join()
|
||||||
{
|
{
|
||||||
#if defined Q_OS_UNIX
|
#if defined Q_OS_UNIX
|
||||||
pthread_join(nativeThreadHandle, 0);
|
pthread_join(nativeThreadHandle, nullptr);
|
||||||
#elif defined Q_OS_WIN
|
#elif defined Q_OS_WIN
|
||||||
WaitForSingleObjectEx(nativeThreadHandle, INFINITE, FALSE);
|
WaitForSingleObjectEx(nativeThreadHandle, INFINITE, FALSE);
|
||||||
CloseHandle(nativeThreadHandle);
|
CloseHandle(nativeThreadHandle);
|
||||||
@ -720,7 +720,7 @@ void *NativeThreadWrapper::runUnix(void *that)
|
|||||||
nativeThreadWrapper->stopCondition.wait(lock.mutex());
|
nativeThreadWrapper->stopCondition.wait(lock.mutex());
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data)
|
unsigned WIN_FIX_STDCALL NativeThreadWrapper::runWin(void *data)
|
||||||
@ -736,12 +736,12 @@ void NativeThreadWrapper::stop()
|
|||||||
stopCondition.wakeOne();
|
stopCondition.wakeOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool threadAdoptedOk = false;
|
static bool threadAdoptedOk = false;
|
||||||
QThread *mainThread;
|
static QThread *mainThread;
|
||||||
void testNativeThreadAdoption(void *)
|
void testNativeThreadAdoption(void *)
|
||||||
{
|
{
|
||||||
threadAdoptedOk = (QThread::currentThreadId() != 0
|
threadAdoptedOk = (QThread::currentThreadId() != nullptr
|
||||||
&& QThread::currentThread() != 0
|
&& QThread::currentThread() != nullptr
|
||||||
&& QThread::currentThread() != mainThread);
|
&& QThread::currentThread() != mainThread);
|
||||||
}
|
}
|
||||||
void tst_QThread::nativeThreadAdoption()
|
void tst_QThread::nativeThreadAdoption()
|
||||||
@ -769,7 +769,7 @@ void adoptedThreadAffinityFunction(void *arg)
|
|||||||
|
|
||||||
void tst_QThread::adoptedThreadAffinity()
|
void tst_QThread::adoptedThreadAffinity()
|
||||||
{
|
{
|
||||||
QThread *affinity[2] = { 0, 0 };
|
QThread *affinity[2] = { nullptr, nullptr };
|
||||||
|
|
||||||
NativeThreadWrapper thread;
|
NativeThreadWrapper thread;
|
||||||
thread.startAndWait(adoptedThreadAffinityFunction, affinity);
|
thread.startAndWait(adoptedThreadAffinityFunction, affinity);
|
||||||
@ -1142,7 +1142,7 @@ void tst_QThread::startFinishRace()
|
|||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
if (!i) disconnect(this, SIGNAL(finished()), 0, 0);
|
if (!i) disconnect(this, SIGNAL(finished()), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
int i;
|
int i;
|
||||||
};
|
};
|
||||||
|
@ -112,7 +112,7 @@ void tst_QThreadOnce::sameThread()
|
|||||||
QCOMPARE(controlVariable, 1);
|
QCOMPARE(controlVariable, 1);
|
||||||
|
|
||||||
static QSingleton<SingletonObject> s;
|
static QSingleton<SingletonObject> s;
|
||||||
QTEST((int)s->val.loadRelaxed(), "expectedValue");
|
QTEST(int(s->val.loadRelaxed()), "expectedValue");
|
||||||
s->val.ref();
|
s->val.ref();
|
||||||
|
|
||||||
QCOMPARE(SingletonObject::runCount, 1);
|
QCOMPARE(SingletonObject::runCount, 1);
|
||||||
@ -145,7 +145,7 @@ void tst_QThreadOnce::multipleThreads()
|
|||||||
delete parent;
|
delete parent;
|
||||||
|
|
||||||
QCOMPARE(controlVariable, 1);
|
QCOMPARE(controlVariable, 1);
|
||||||
QCOMPARE((int)IncrementThread::runCount.loadRelaxed(), NumberOfThreads);
|
QCOMPARE(int(IncrementThread::runCount.loadRelaxed()), NumberOfThreads);
|
||||||
QCOMPARE(SingletonObject::runCount, 1);
|
QCOMPARE(SingletonObject::runCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ tst_QThreadPool::~tst_QThreadPool()
|
|||||||
tst_QThreadPool::functionTestMutex = nullptr;
|
tst_QThreadPool::functionTestMutex = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testFunctionCount;
|
static int testFunctionCount;
|
||||||
|
|
||||||
void sleepTestFunction()
|
void sleepTestFunction()
|
||||||
{
|
{
|
||||||
@ -225,7 +225,7 @@ void tst_QThreadPool::waitcomplete()
|
|||||||
QCOMPARE(testFunctionCount, runs);
|
QCOMPARE(testFunctionCount, runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAtomicInt ran; // bool
|
static QAtomicInt ran; // bool
|
||||||
class TestTask : public QRunnable
|
class TestTask : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -253,7 +253,7 @@ void tst_QThreadPool::singleton()
|
|||||||
QTRY_VERIFY(ran.loadRelaxed());
|
QTRY_VERIFY(ran.loadRelaxed());
|
||||||
}
|
}
|
||||||
|
|
||||||
QAtomicInt *value = 0;
|
static QAtomicInt *value = nullptr;
|
||||||
class IntAccessor : public QRunnable
|
class IntAccessor : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -278,11 +278,11 @@ void tst_QThreadPool::destruction()
|
|||||||
threadManager->start(new IntAccessor());
|
threadManager->start(new IntAccessor());
|
||||||
delete threadManager;
|
delete threadManager;
|
||||||
delete value;
|
delete value;
|
||||||
value = 0;
|
value = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSemaphore threadRecyclingSemaphore;
|
static QSemaphore threadRecyclingSemaphore;
|
||||||
QThread *recycledThread = nullptr;
|
static QThread *recycledThread = nullptr;
|
||||||
|
|
||||||
class ThreadRecorderTask : public QRunnable
|
class ThreadRecorderTask : public QRunnable
|
||||||
{
|
{
|
||||||
@ -328,7 +328,7 @@ public:
|
|||||||
QSemaphore semaphore;
|
QSemaphore semaphore;
|
||||||
|
|
||||||
ExpiryTimeoutTask()
|
ExpiryTimeoutTask()
|
||||||
: thread(0), runCount(0)
|
: thread(nullptr), runCount(0)
|
||||||
{
|
{
|
||||||
setAutoDelete(false);
|
setAutoDelete(false);
|
||||||
}
|
}
|
||||||
@ -720,7 +720,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
|
|||||||
threadpool->setMaxThreadCount(savedLimit);
|
threadpool->setMaxThreadCount(savedLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAtomicInt count;
|
static QAtomicInt count;
|
||||||
class CountingRunnable : public QRunnable
|
class CountingRunnable : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -772,9 +772,9 @@ void tst_QThreadPool::tryStart()
|
|||||||
QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount());
|
QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex mutex;
|
static QMutex mutex;
|
||||||
QAtomicInt activeThreads;
|
static QAtomicInt activeThreads;
|
||||||
QAtomicInt peakActiveThreads;
|
static QAtomicInt peakActiveThreads;
|
||||||
void tst_QThreadPool::tryStartPeakThreadCount()
|
void tst_QThreadPool::tryStartPeakThreadCount()
|
||||||
{
|
{
|
||||||
class CounterTask : public QRunnable
|
class CounterTask : public QRunnable
|
||||||
@ -868,7 +868,7 @@ void tst_QThreadPool::priorityStart()
|
|||||||
Runner(QAtomicPointer<QRunnable> &ptr) : ptr(ptr) {}
|
Runner(QAtomicPointer<QRunnable> &ptr) : ptr(ptr) {}
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
ptr.testAndSetRelaxed(0, this);
|
ptr.testAndSetRelaxed(nullptr, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1017,7 +1017,7 @@ void tst_QThreadPool::tryTake()
|
|||||||
explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r)
|
explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r)
|
||||||
: sem(s), startedThreads(started), dtorCounter(c), runCounter(r) {}
|
: sem(s), startedThreads(started), dtorCounter(c), runCounter(r) {}
|
||||||
|
|
||||||
~BlockingRunnable()
|
~BlockingRunnable() override
|
||||||
{
|
{
|
||||||
dtorCounter.fetchAndAddRelaxed(1);
|
dtorCounter.fetchAndAddRelaxed(1);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ void tst_QThreadStorage::hasLocalData()
|
|||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
pointers.setLocalData(new Pointer);
|
pointers.setLocalData(new Pointer);
|
||||||
QVERIFY(pointers.hasLocalData());
|
QVERIFY(pointers.hasLocalData());
|
||||||
pointers.setLocalData(0);
|
pointers.setLocalData(nullptr);
|
||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ void tst_QThreadStorage::localData()
|
|||||||
pointers.setLocalData(p);
|
pointers.setLocalData(p);
|
||||||
QVERIFY(pointers.hasLocalData());
|
QVERIFY(pointers.hasLocalData());
|
||||||
QCOMPARE(pointers.localData(), p);
|
QCOMPARE(pointers.localData(), p);
|
||||||
pointers.setLocalData(0);
|
pointers.setLocalData(nullptr);
|
||||||
QCOMPARE(pointers.localData(), (Pointer *)0);
|
QCOMPARE(pointers.localData(), nullptr);
|
||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ void tst_QThreadStorage::localData_const()
|
|||||||
pointers.setLocalData(p);
|
pointers.setLocalData(p);
|
||||||
QVERIFY(pointers.hasLocalData());
|
QVERIFY(pointers.hasLocalData());
|
||||||
QCOMPARE(const_pointers.localData(), p);
|
QCOMPARE(const_pointers.localData(), p);
|
||||||
pointers.setLocalData(0);
|
pointers.setLocalData(nullptr);
|
||||||
QCOMPARE(const_pointers.localData(), (Pointer *)0);
|
QCOMPARE(const_pointers.localData(), nullptr);
|
||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ void tst_QThreadStorage::setLocalData()
|
|||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
pointers.setLocalData(new Pointer);
|
pointers.setLocalData(new Pointer);
|
||||||
QVERIFY(pointers.hasLocalData());
|
QVERIFY(pointers.hasLocalData());
|
||||||
pointers.setLocalData(0);
|
pointers.setLocalData(nullptr);
|
||||||
QVERIFY(!pointers.hasLocalData());
|
QVERIFY(!pointers.hasLocalData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ void tst_QThreadStorage::autoDelete()
|
|||||||
QCOMPARE(Pointer::count, c);
|
QCOMPARE(Pointer::count, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool threadStorageOk;
|
static bool threadStorageOk;
|
||||||
void testAdoptedThreadStorageWin(void *p)
|
void testAdoptedThreadStorageWin(void *p)
|
||||||
{
|
{
|
||||||
QThreadStorage<Pointer *> *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p);
|
QThreadStorage<Pointer *> *pointers = reinterpret_cast<QThreadStorage<Pointer *> *>(p);
|
||||||
@ -183,7 +183,7 @@ void testAdoptedThreadStorageWin(void *p)
|
|||||||
void *testAdoptedThreadStorageUnix(void *pointers)
|
void *testAdoptedThreadStorageUnix(void *pointers)
|
||||||
{
|
{
|
||||||
testAdoptedThreadStorageWin(pointers);
|
testAdoptedThreadStorageWin(pointers);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
void tst_QThreadStorage::adoptedThreads()
|
void tst_QThreadStorage::adoptedThreads()
|
||||||
{
|
{
|
||||||
@ -194,9 +194,9 @@ void tst_QThreadStorage::adoptedThreads()
|
|||||||
{
|
{
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
const int state = pthread_create(&thread, 0, testAdoptedThreadStorageUnix, &pointers);
|
const int state = pthread_create(&thread, nullptr, testAdoptedThreadStorageUnix, &pointers);
|
||||||
QCOMPARE(state, 0);
|
QCOMPARE(state, 0);
|
||||||
pthread_join(thread, 0);
|
pthread_join(thread, nullptr);
|
||||||
#elif defined Q_OS_WIN
|
#elif defined Q_OS_WIN
|
||||||
HANDLE thread;
|
HANDLE thread;
|
||||||
thread = (HANDLE)_beginthread(testAdoptedThreadStorageWin, 0, &pointers);
|
thread = (HANDLE)_beginthread(testAdoptedThreadStorageWin, 0, &pointers);
|
||||||
@ -212,7 +212,7 @@ void tst_QThreadStorage::adoptedThreads()
|
|||||||
QTRY_COMPARE(Pointer::count, c);
|
QTRY_COMPARE(Pointer::count, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
|
static QBasicAtomicInt cleanupOrder = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||||
|
|
||||||
class First
|
class First
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
QWaitCondition *cond;
|
QWaitCondition *cond;
|
||||||
|
|
||||||
inline wait_QMutex_Thread_2()
|
inline wait_QMutex_Thread_2()
|
||||||
: mutex(0), cond(0)
|
: mutex(nullptr), cond(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
@ -134,7 +134,7 @@ public:
|
|||||||
QWaitCondition *cond;
|
QWaitCondition *cond;
|
||||||
|
|
||||||
inline wait_QReadWriteLock_Thread_2()
|
inline wait_QReadWriteLock_Thread_2()
|
||||||
: readWriteLock(0), cond(0)
|
: readWriteLock(nullptr), cond(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
@ -392,7 +392,7 @@ public:
|
|||||||
QWaitCondition *cond;
|
QWaitCondition *cond;
|
||||||
|
|
||||||
inline wake_Thread()
|
inline wake_Thread()
|
||||||
: mutex(0), cond(0)
|
: mutex(nullptr), cond(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
static inline void sleep(ulong s)
|
static inline void sleep(ulong s)
|
||||||
@ -424,7 +424,7 @@ public:
|
|||||||
QWaitCondition *cond;
|
QWaitCondition *cond;
|
||||||
|
|
||||||
inline wake_Thread_2()
|
inline wake_Thread_2()
|
||||||
: readWriteLock(0), cond(0)
|
: readWriteLock(nullptr), cond(nullptr)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
static inline void sleep(ulong s)
|
static inline void sleep(ulong s)
|
||||||
|
@ -109,7 +109,7 @@ void tst_QWriteLocker::scopeTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ void tst_QWriteLocker::unlockAndRelockTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QWriteLocker::lockerStateTest()
|
void tst_QWriteLocker::lockerStateTest()
|
||||||
@ -196,7 +196,7 @@ void tst_QWriteLocker::lockerStateTest()
|
|||||||
QVERIFY(thread->wait());
|
QVERIFY(thread->wait());
|
||||||
|
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = 0;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QWriteLocker)
|
QTEST_MAIN(tst_QWriteLocker)
|
||||||
|
Loading…
Reference in New Issue
Block a user