#include <RunThread.h>
Public Member Functions | |
| RunThread () | |
| RunThread (Handle< T > alg) | |
| ~RunThread () | |
| void | Run (bool new_thread) |
| int | Join (void) |
| Handle< T > | GetAlg () |
| T * | operator-> () const |
| void | release () |
| bool | valid () const |
Private Attributes | |
| Mutex | fMutex |
| pthread_t | fThread |
| int | fThreadStatus |
| Handle< T > | fAlg |
|
|||||||||
|
Definition at line 85 of file RunThread.h. 00086 : fMutex(), fThread(), fThreadStatus(1), fAlg() {}
|
|
||||||||||
|
Definition at line 89 of file RunThread.h. 00090 : fMutex(), fThread(), fThreadStatus(1), fAlg(alg) {}
|
|
|||||||||
|
Definition at line 93 of file RunThread.h. 00093 {}
|
|
|||||||||
|
Definition at line 147 of file RunThread.h. 00148 {
00149 return fAlg;
00150 }
|
|
||||||||||
|
Definition at line 133 of file RunThread.h. References Anp::RunThread< T >::fThread, and Anp::RunThread< T >::fThreadStatus. 00134 {
00135 //
00136 // If there is parallel thread running then attempt to join to main thread
00137 //
00138 if(fThreadStatus == 0)
00139 {
00140 return pthread_join(fThread, NULL);
00141 }
00142
00143 return fThreadStatus;
00144 }
|
|
|||||||||
|
Definition at line 153 of file RunThread.h. References Anp::RunThread< T >::fAlg.
|
|
|||||||||
|
Definition at line 166 of file RunThread.h. References Anp::RunThread< T >::fAlg. 00167 {
00168 fAlg.release();
00169 }
|
|
||||||||||
|
Definition at line 96 of file RunThread.h. References Anp::RunThread< T >::fAlg, Anp::RunThread< T >::fMutex, Anp::RunThread< T >::fThread, and Anp::RunThread< T >::fThreadStatus. 00097 {
00098 if(!fAlg.valid()) return;
00099
00100 if(new_thread)
00101 {
00102 //
00103 // Lock mutex ONLY when starting new thread
00104 //
00105 Anp::Lock<Mutex> lock(fMutex);
00106
00107 //
00108 // Run algorithm in NEW thread
00109 //
00110 fThreadStatus = pthread_create(&fThread, NULL, Anp::get_thread_done<T>, fAlg.get());
00111
00112 if(fThreadStatus != 0)
00113 {
00114 std::cerr << "RunThread::Run - invalid thread status: " << fThreadStatus << std::endl;
00115 }
00116 }
00117 else
00118 {
00119 //
00120 // No thread is created, set thread status to 1,
00121 // so that we do not try later to join same thread.
00122 //
00123 fThreadStatus = 1;
00124
00125 //
00126 // Run algorithm in this thread
00127 //
00128 Anp::get_thread_done<T>(fAlg.get());
00129 }
00130 }
|
|
|||||||||
|
Definition at line 160 of file RunThread.h. References Anp::RunThread< T >::fAlg. 00161 {
00162 return fAlg.valid();
00163 }
|
|
|||||
|
Definition at line 59 of file RunThread.h. Referenced by Anp::RunThread< T >::operator->(), Anp::RunThread< T >::release(), Anp::RunThread< T >::Run(), and Anp::RunThread< T >::valid(). |
|
|||||
|
Definition at line 55 of file RunThread.h. Referenced by Anp::RunThread< T >::Run(). |
|
|||||
|
Definition at line 56 of file RunThread.h. Referenced by Anp::RunThread< T >::Join(), and Anp::RunThread< T >::Run(). |
|
|||||
|
Definition at line 57 of file RunThread.h. Referenced by Anp::RunThread< T >::Join(), and Anp::RunThread< T >::Run(). |
1.3.9.1