ThreadWeaver
Job.h
Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 00003 This file declares the Job class. 00004 00005 $ Author: Mirko Boehm $ 00006 $ Copyright: (C) 2004, 2005, 2006 Mirko Boehm $ 00007 $ Contact: mirko@kde.org 00008 http://www.kde.org 00009 http://www.hackerbuero.org $ 00010 00011 This library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU Library General Public 00013 License as published by the Free Software Foundation; either 00014 version 2 of the License, or (at your option) any later version. 00015 00016 This library is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Library General Public License for more details. 00020 00021 You should have received a copy of the GNU Library General Public License 00022 along with this library; see the file COPYING.LIB. If not, write to 00023 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00024 Boston, MA 02110-1301, USA. 00025 00026 $Id: Job.h 32 2005-08-17 08:38:01Z mirko $ 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 // FIXME (Mirko) this should be private, I guess? 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 // QMutex& mutex(); 00235 00236 }; 00237 } 00238 00239 #endif // THREADWEAVER_JOB_H 00240
KDE 4.6 API Reference