Rev 1026 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1026 | Rev 1124 | ||
|---|---|---|---|
| Line 21... | Line 21... | ||
| 21 | 21 | ||
| 22 | #ifndef _THREAD_H |
22 | #ifndef _THREAD_H |
| 23 | #define _THREAD_H |
23 | #define _THREAD_H |
| 24 | 24 | ||
| 25 | #include <pthread.h> |
25 | #include <pthread.h> |
| - | 26 | #include <iostream> |
|
| 26 | 27 | ||
| 27 | template <class T> |
28 | template <class T> |
| 28 | class Thread |
29 | class Thread |
| 29 | { |
30 | { |
| 30 | public: |
31 | public: |
| Line 38... | Line 39... | ||
| 38 | stop(); |
39 | stop(); |
| 39 | }; |
40 | }; |
| 40 | 41 | ||
| 41 | bool stop() |
42 | bool stop() |
| 42 | { |
43 | { |
| - | 44 | ||
| 43 | if (!myIsCreated) |
45 | if (!myIsCreated) |
| - | 46 | { |
|
| - | 47 | //cout << "Thread is not running, can not be stopped " << endl; |
|
| 44 | return true; |
48 | return true; |
| - | 49 | } |
|
| - | 50 | ||
| - | 51 | //cout << "Thread cancel to run " << endl; |
|
| - | 52 | ||
| - | 53 | //myError = pthread_cancel(myHandle); |
|
| - | 54 | myError = pthread_detach(myHandle); |
|
| - | 55 | //cout << "Thread cancel returned " << myError << endl; |
|
| - | 56 | ||
| - | 57 | ||
| - | 58 | ||
| - | 59 | //if (joinThread) |
|
| - | 60 | { |
|
| - | 61 | //join(); |
|
| - | 62 | } |
|
| 45 | 63 | ||
| 46 | myError = pthread_cancel(myHandle); |
- | |
| 47 | join(); |
- | |
| 48 | myIsCreated = false; |
64 | myIsCreated = false; |
| 49 | 65 | ||
| 50 | return myError == 0; |
66 | return myError == 0; |
| 51 | }; |
67 | }; |
| 52 | 68 | ||