krita

kis_thread_pool.h

00001 /*
00002  *  copyright (c) 2006 Boudewijn Rempt
00003  *
00004  *  This program is free software; you can distribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #ifndef KIS_THREAD_POOL_
00020 #define KIS_THREAD_POOL_
00021 
00022 #include <qthread.h>
00023 #include <qptrlist.h>
00024 #include <qmutex.h>
00025 
00026 #include "kis_thread.h"
00027 
00036 class KisThreadPool : public KisThread {
00037 
00038 public:
00039 
00040     virtual ~KisThreadPool();
00041 
00042     static KisThreadPool * instance();
00043 
00044     void enqueue(KisThread * thread);
00045     void dequeue(KisThread * thread);
00046     
00047     void run();
00048     
00049     
00050     KisThreadPool();
00051 
00052 private:
00053 
00054     KisThreadPool(const KisThreadPool&);
00055     KisThreadPool operator=(const KisThreadPool&);
00056 
00057     QMutex m_poolMutex;
00058     int m_numberOfRunningThreads;
00059     int m_numberOfQueuedThreads;
00060     int m_maxThreads;
00061     int m_wait;
00062     QPtrList<KisThread> m_threads;
00063     QPtrList<KisThread> m_runningThreads;
00064     QPtrList<KisThread> m_oldThreads;
00065     
00066     static KisThreadPool * m_singleton;
00067 };
00068 
00069 
00070 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys