Revision 28, 1.3 kB
(checked in by wagi, 19 years ago)
|
WorkerThread? added.
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
Line | |
---|
1 |
/* workerthread.h |
---|
2 |
* Copyright (C) 2004 by Daniel Wagner |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob is free software; you can redistribute it and/or modify |
---|
7 |
* it under the terms of the GNU General Public License as published by |
---|
8 |
* the Free Software Foundation; either version 2 of the License, or |
---|
9 |
* (at your option) any later version. |
---|
10 |
* FreeBob is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
#ifndef WORKERTHREAD_H |
---|
21 |
#define WORKERTHREAD_H |
---|
22 |
|
---|
23 |
#include <queue> |
---|
24 |
|
---|
25 |
#include <pthread.h> |
---|
26 |
|
---|
27 |
class Functor; |
---|
28 |
|
---|
29 |
class WorkerThread { |
---|
30 |
public: |
---|
31 |
static WorkerThread* instance(); |
---|
32 |
|
---|
33 |
void addFunctor( Functor* pFunctor ); |
---|
34 |
|
---|
35 |
protected: |
---|
36 |
static void* workerThread( void* arg ); |
---|
37 |
void run(); |
---|
38 |
|
---|
39 |
private: |
---|
40 |
WorkerThread(); |
---|
41 |
virtual ~WorkerThread(); |
---|
42 |
|
---|
43 |
static WorkerThread* m_pInstance; |
---|
44 |
|
---|
45 |
pthread_t m_thread; |
---|
46 |
pthread_mutex_t m_mutex; |
---|
47 |
pthread_cond_t m_cond; |
---|
48 |
pthread_mutex_t m_cond_mutex; |
---|
49 |
std::queue< Functor* > m_queue; |
---|
50 |
}; |
---|
51 |
|
---|
52 |
#endif |
---|