#include <QtConcurrent/qtconcurrentmedian.h>
#include <QtConcurrent/qtconcurrentthreadengine.h>
-#ifndef QT_NO_STL
-# include <iterator>
-#endif
+#include <iterator>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
namespace QtConcurrent {
-#ifndef QT_NO_STL
using std::advance;
-#else
- template <typename It, typename T>
- void advance(It &it, T value)
- {
- it+=value;
- }
-#endif
/*
The BlockSizeManager class manages how many iterations a thread should
inline void * getPointer() { return 0; }
};
-#ifndef QT_NO_STL
inline bool selectIteration(std::bidirectional_iterator_tag)
{
return false; // while
{
return true; // for
}
-#else
-// no stl support, always use while iteration
-template <typename T>
-inline bool selectIteration(T)
-{
- return false; // while
-}
-#endif
template <typename Iterator, typename T>
class IterateKernel : public ThreadEngine<T>
typedef T ResultType;
IterateKernel(Iterator _begin, Iterator _end)
-#if defined (QT_NO_STL)
- : begin(_begin), end(_end), current(_begin), currentIndex(0),
- forIteration(false), progressReportingEnabled(true)
-#else
: begin(_begin), end(_end), current(_begin), currentIndex(0),
forIteration(selectIteration(typename std::iterator_traits<Iterator>::iterator_category())), progressReportingEnabled(true)
-#endif
{
-#if defined (QT_NO_STL)
- iterationCount = 0;
-#else
iterationCount = forIteration ? std::distance(_begin, _end) : 0;
-
-#endif
}
virtual ~IterateKernel() { }
void resultAt();
void incrementalResults();
void noDetach();
-#ifndef QT_NO_STL
void stlContainers();
-#endif
};
void tst_QtConcurrentFilter::filter()
}
}
-#ifndef QT_NO_STL
void tst_QtConcurrentFilter::stlContainers()
{
std::vector<int> vector;
QCOMPARE(list2.size(), (std::list<int>::size_type)(1));
QCOMPARE(*list2.begin(), 1);
}
-#endif
QTEST_MAIN(tst_QtConcurrentFilter)
#include "tst_qtconcurrentfilter.moc"
};
#include <qiterator.h>
-#ifndef QT_NO_STL
namespace std {
template <>
struct iterator_traits<TestIterator>
}
}
-#endif
#include <qtconcurrentiteratekernel.h>
#include <QtTest/QtTest>
void stresstest();
void noIterations();
void throttling();
-#ifndef QT_NO_STL
void blockSize();
void multipleResults();
-#endif
};
QAtomicInt iterations;
}
};
-// Missing stl iterators prevent correct block size calculation.
-#ifndef QT_NO_STL
void tst_QtConcurrentIterateKernel::blockSize()
{
const int expectedMinimumBlockSize = 1024 / QThread::idealThreadCount();
qDebug() << "block size" << peakBlockSize;
QVERIFY(peakBlockSize >= expectedMinimumBlockSize);
}
-#endif
class MultipleResultsFor : public IterateKernel<TestIterator, int>
{
}
};
-// Missing stl iterators prevent correct summation.
-#ifndef QT_NO_STL
void tst_QtConcurrentIterateKernel::multipleResults()
{
QFuture<int> f = startThreadEngine(new MultipleResultsFor(0, 10)).startAsynchronously();
QCOMPARE(f.resultAt(9), 9);
f.waitForFinished();
}
-#endif
QTEST_MAIN(tst_QtConcurrentIterateKernel)
#endif
void incrementalResults();
void noDetach();
-#ifndef QT_NO_STL
void stlContainers();
-#endif
void qFutureAssignmentLeak();
void stressTest();
public slots:
}
-#ifndef QT_NO_STL
void tst_QtConcurrentMap::stlContainers()
{
std::vector<int> vector;
QtConcurrent::blockingMap(list, multiplyBy2Immutable);
}
-#endif
InstanceCounter ic_fn(const InstanceCounter & ic)
{