| Line | |
|---|
| 1 | #ifndef MTHREAD_H
|
|---|
| 2 | #define MTHREAD_H
|
|---|
| 3 |
|
|---|
| 4 | #include <pthread.h>
|
|---|
| 5 |
|
|---|
| 6 | class MThread
|
|---|
| 7 | {
|
|---|
| 8 | private:
|
|---|
| 9 | bool fIsRunning;
|
|---|
| 10 | bool fIsDetached;
|
|---|
| 11 | bool fStop;
|
|---|
| 12 |
|
|---|
| 13 | pthread_t *fThread;
|
|---|
| 14 |
|
|---|
| 15 | void *fReturn;
|
|---|
| 16 |
|
|---|
| 17 | int fPriority;
|
|---|
| 18 |
|
|---|
| 19 | static void *MapThread(void *arg);
|
|---|
| 20 | void *RunThread();
|
|---|
| 21 | virtual void *Thread() = 0;
|
|---|
| 22 |
|
|---|
| 23 | public:
|
|---|
| 24 | MThread(bool start=true);
|
|---|
| 25 | virtual ~MThread();
|
|---|
| 26 |
|
|---|
| 27 | bool SetPriority(int prio);
|
|---|
| 28 |
|
|---|
| 29 | void Detach();
|
|---|
| 30 |
|
|---|
| 31 | void Start();
|
|---|
| 32 | void Stop();
|
|---|
| 33 |
|
|---|
| 34 | bool HasStopFlag() const { return fStop; }
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.