ThreadWeaver
Job.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THREADWEAVER_JOB_H
00030 #define THREADWEAVER_JOB_H
00031
00032 #include <QtCore/QObject>
00033
00034 #include <threadweaver/threadweaver_export.h>
00035
00036 class QMutex;
00037 class QWaitCondition;
00038
00039 namespace ThreadWeaver {
00040
00041 class Thread;
00042 class QueuePolicy;
00043 class JobRunHelper;
00044 class WeaverInterface;
00045 class QueuePolicyList;
00046
00065 class THREADWEAVER_EXPORT Job : public QObject
00066 {
00067 Q_OBJECT
00068
00069 public:
00070 friend class JobRunHelper;
00071
00076 explicit Job ( QObject* parent = 0 );
00077
00079 virtual ~Job();
00080
00085 virtual void execute(Thread*);
00086
00101 virtual int priority() const;
00102
00118 virtual bool success () const;
00119
00134
00135 virtual void requestAbort () {}
00136
00150 virtual void aboutToBeQueued ( WeaverInterface *weaver );
00151
00165 virtual void aboutToBeDequeued ( WeaverInterface *weaver );
00166
00175 virtual bool canBeExecuted();
00176
00178 bool isFinished() const;
00179
00187 void assignQueuePolicy ( QueuePolicy* );
00188
00191 void removeQueuePolicy ( QueuePolicy* );
00192
00193 Q_SIGNALS:
00196 void started ( ThreadWeaver::Job* );
00202 void done ( ThreadWeaver::Job* );
00203
00208 void failed( ThreadWeaver::Job* );
00209
00210 protected:
00211 class Private;
00212 Private* d;
00213
00216 void freeQueuePolicyResources();
00217
00221 virtual void run () = 0;
00228 Thread *thread();
00229
00231 void setFinished ( bool status );
00232
00234
00235
00236 };
00237 }
00238
00239 #endif // THREADWEAVER_JOB_H
00240