ThreadWeaver
ThreadWeaver.h
Go to the documentation of this file.
00001 /* -*- C++ -*- 00002 00003 This file implements the public interfaces of the Weaver and the Job class. 00004 It should be the only include file necessary to use the ThreadWeaver 00005 library. 00006 00007 $ Author: Mirko Boehm $ 00008 $ Copyright: (C) 2005, Mirko Boehm $ 00009 $ Contact: mirko@kde.org 00010 http://www.kde.org 00011 http://www.hackerbuero.org $ 00012 00013 This library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU Library General Public 00015 License as published by the Free Software Foundation; either 00016 version 2 of the License, or (at your option) any later version. 00017 00018 This library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 Library General Public License for more details. 00022 00023 You should have received a copy of the GNU Library General Public License 00024 along with this library; see the file COPYING.LIB. If not, write to 00025 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00026 Boston, MA 02110-1301, USA. 00027 00028 $Id: ThreadWeaver.h 32 2005-08-17 08:38:01Z mirko $ 00029 */ 00030 #ifndef THREADWEAVER_H 00031 #define THREADWEAVER_H 00032 00033 #include <QtCore/QObject> 00034 #include "WeaverInterface.h" 00035 00036 namespace ThreadWeaver { 00037 00038 class Job; 00039 class State; 00040 class WeaverObserver; 00041 00064 // Note: All member documentation is in the WeaverInterface class. 00065 class THREADWEAVER_EXPORT Weaver : public WeaverInterface 00066 { 00067 Q_OBJECT 00068 public: 00070 Weaver ( QObject* parent=0 ); 00071 00073 virtual ~Weaver (); 00074 00075 const State& state() const; 00076 00077 void setMaximumNumberOfThreads( int cap ); 00078 int maximumNumberOfThreads() const; 00079 int currentNumberOfThreads () const; 00080 00081 00082 void registerObserver ( WeaverObserver* ); 00083 00091 // FIXME (0.7) this should be a WeaverInterface pointer 00092 static ThreadWeaver::Weaver* instance(); 00093 virtual void enqueue (Job*); 00094 virtual bool dequeue (Job*); 00095 virtual void dequeue (); 00096 virtual void finish(); 00097 virtual void suspend( ); 00098 virtual void resume(); 00099 bool isEmpty () const; 00100 bool isIdle () const; 00101 int queueLength () const; 00102 void requestAbort(); 00103 00104 protected: 00105 00109 virtual WeaverInterface* makeWeaverImpl (); 00110 00111 private: 00112 00113 class Private; 00114 Private* const d; 00115 }; 00116 } 00117 00118 #endif // THREADWEAVER_H
KDE 4.6 API Reference