Using QThreadPool in MandelbrotCalculator
Now that our Job
class is ready to be used, we need to create a class to manage the jobs. Please create a new class, MandelbrotCalculator
. Let's see what we need in the file, MandelbrotCalculator.h
:
#include <QObject> #include <QSize> #include <QPointF> #include <QElapsedTimer> #include <QList> #include "JobResult.h" class Job; class MandelbrotCalculator : public QObject { Q_OBJECT public: explicit MandelbrotCalculator(QObject *parent = 0); void init(QSize imageSize); private: QPointF mMoveOffset; double mScaleFactor; QSize mAreaSize; int mIterationMax; int mReceivedJobResults; QList<JobResult> mJobResults; QElapsedTimer mTimer; };
We have already discussed mMoveOffset
, mScaleFactor
, mAreaSize
, and mIterationMax
in the previous section. We also have some new variables:
The
mReceivedJobResults
variable is the count of theJobResult
received, which...