Interacting with sockets in the worker
Now that the SDK is completed, we can turn to the worker. The project is complex enough; we can refresh our memory with the mandelbrot-worker
architecture:
We will start by implementing the Job
class. Inside the mandelbrot-worker
project, create a new C++ class named Job
. Here is the Job.h
content:
#include <QObject> #include <QRunnable> #include <QAtomicInteger> #include "JobRequest.h" #include "JobResult.h" class Job : public QObject, public QRunnable { Q_OBJECT public: explicit Job(const JobRequest& jobRequest, QObject *parent = 0); void run() override; signals: void jobCompleted(JobResult jobResult); public slots: void abort(); private: QAtomicInteger<bool> mAbort; JobRequest mJobRequest; };
If you remember the Job
class from Chapter 9, Keeping Your Sanity with Multithreading, this header should ring a bell. The only difference is that the parameters...