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
00062 class THREADWEAVER_EXPORT Job : public QObject
00063 {
00064 Q_OBJECT
00065
00066 public:
00067 friend class JobRunHelper;
00068
00073 explicit Job ( QObject* parent = 0 );
00074
00076 virtual ~Job();
00077
00082 virtual void execute(Thread*);
00083
00098 virtual int priority() const;
00099
00115 virtual bool success () const;
00116
00131
00132 virtual void requestAbort () {}
00133
00147 virtual void aboutToBeQueued ( WeaverInterface *weaver );
00148
00162 virtual void aboutToBeDequeued ( WeaverInterface *weaver );
00163
00172 virtual bool canBeExecuted();
00173
00175 bool isFinished() const;
00176
00184 void assignQueuePolicy ( QueuePolicy* );
00185
00188 void removeQueuePolicy ( QueuePolicy* );
00189
00190 Q_SIGNALS:
00193 void started ( ThreadWeaver::Job* );
00195 void done ( ThreadWeaver::Job* );
00196
00201 void failed( ThreadWeaver::Job* );
00202
00203 protected:
00204 class Private;
00205 Private* d;
00206
00209 void freeQueuePolicyResources();
00210
00214 virtual void run () = 0;
00221 Thread *thread();
00222
00224 void setFinished ( bool status );
00225
00227
00228
00229 };
00230 }
00231
00232 #endif // THREADWEAVER_JOB_H
00233