chalk

kis_thread_pool.h
1/*
2 * copyright (c) 2006 Boudewijn Rempt
3 *
4 * This program is free software; you can distribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef KIS_THREAD_POOL_
20#define KIS_THREAD_POOL_
21
22#include <tqthread.h>
23#include <tqptrlist.h>
24#include <tqmutex.h>
25
26#include "kis_thread.h"
27
36class KisThreadPool : public KisThread {
37
38public:
39
40 virtual ~KisThreadPool();
41
42 static KisThreadPool * instance();
43
44 void enqueue(KisThread * thread);
45 void dequeue(KisThread * thread);
46
47 void run();
48
49
51
52private:
53
55 KisThreadPool operator=(const KisThreadPool&);
56
57 TQMutex m_poolMutex;
58 int m_numberOfRunningThreads;
59 int m_numberOfQueuedThreads;
60 int m_maxThreads;
61 int m_wait;
62 TQPtrList<KisThread> m_threads;
63 TQPtrList<KisThread> m_runningThreads;
64 TQPtrList<KisThread> m_oldThreads;
65
66 static KisThreadPool * m_singleton;
67};
68
69
70#endif
A thread pool starts executing threads some time after they are added, running a maximum number of th...
A KisThread is a TQThread that can be set in the canceled state.
Definition kis_thread.h:30