Changeset 1953 for trunk/MagicSoft/Cosy/base
- Timestamp:
- 04/12/03 19:06:27 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/base
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/base/MThread.cc
r1275 r1953 5 5 #include <pthread.h> 6 6 #include <sys/resource.h> // PRIO_PROCESS 7 8 #undef DEBUG 7 9 8 10 // ---------------------------------------------------------------------- … … 14 16 MThread::MThread(bool start, int prio) : fIsRunning(false), fIsDetached(false), fThread(NULL), fReturn(NULL) 15 17 { 18 #ifdef DEBUG 19 cout << "MThread::MThread" << endl; 20 #endif 16 21 if (!start) 17 22 return; … … 29 34 MThread::~MThread() 30 35 { 36 #ifdef DEBUG 31 37 cout << "~MThread::MThread" << endl; 38 #endif 32 39 Stop(); 33 40 } … … 122 129 void MThread::Stop() 123 130 { 131 #ifdef DEBUG 124 132 cout << "MThread::Stop: fThread=" << fThread << ", fIsRunning=" << (int)fIsRunning << endl; 133 #endif 134 125 135 if (!fThread || !fIsRunning) 126 136 return; … … 128 138 if (fIsDetached) 129 139 { 140 #ifdef DEBUG 130 141 cout << "Stopping detached thread..." << flush; 142 #endif 131 143 pthread_cancel(*fThread); 132 144 fIsRunning = false; … … 134 146 else 135 147 { 148 #ifdef DEBUG 136 149 cout << "Stopping thread..." << flush; 150 #endif 137 151 fStop = true; 138 152 pthread_join(*fThread, &fReturn); 139 153 } 154 #ifdef DEBUG 140 155 cout << "done." << endl; 156 #endif 141 157 142 158 delete fThread; 143 159 fThread = NULL; 144 160 161 #ifdef DEBUG 145 162 cout << "MThread::Stop() done." << endl; 163 #endif 146 164 } -
trunk/MagicSoft/Cosy/base/msgqueue.cc
r1727 r1953 6 6 #include <sys/resource.h> // PRIO_PROCESS 7 7 8 #undef DEBUG 9 8 10 // -------------------------------------------------------------------------- 9 11 // … … 22 24 MsgQueue::~MsgQueue() 23 25 { 26 #ifdef DEBUG 24 27 cout << "~MsgQueue::MsgQueue" << endl; 28 #endif 25 29 pthread_cancel(fThread); 26 30 delete (unsigned char*)fMp; … … 89 93 pthread_mutex_unlock(&fMuxMsg); 90 94 95 #ifdef DEBUG 91 96 cout << "MsgQueue::Thread: Processing Msg 0x" << hex << fMsg << endl; 97 #endif 92 98 // --- bool quit = fMsg==WM_QUIT; 93 99 fRc=Proc(fMsg, fMp); 100 #ifdef DEBUG 94 101 cout << "MsgQueue::PostMsg: Msg 0x" << hex << fMsg << " processed (rc=" << fRc << ")" << endl; 102 #endif 95 103 96 104 // --- if (quit) … … 119 127 // stopped and the messages are processed serialized 120 128 // 129 #ifdef DEBUG 121 130 cout << "MsgQueue::PostMsg: Locking MsgQueue mutex..." << flush; 131 #endif 122 132 pthread_mutex_lock(&fMuxMsg); 133 #ifdef DEBUG 123 134 cout << "done." << endl; 135 #endif 124 136 125 137 // … … 134 146 { 135 147 pthread_mutex_unlock(&fMuxMsg); 148 #ifdef DEBUG 136 149 cout << "------------> MsgQueue::PostMsg: Proc still pending... Message IGNORED." << endl; 150 #endif 137 151 return NULL; 138 152 } 139 153 /**** NEW 20/01/2003 ****/ 154 #ifdef DEBUG 140 155 cout << "MsgQueue::PostMsg: ---> Break <---" << endl; 156 #endif 141 157 fBreak = 1; 142 158 … … 156 172 // Start Proc() 157 173 // 174 #ifdef DEBUG 158 175 cout << "MsgQueue::PostMsg: Releasing MsgQueue mutex..." << flush; 176 #endif 159 177 fStart = 1; 160 178 pthread_mutex_unlock(&fMuxMsg); 179 #ifdef DEBUG 161 180 cout << "done." << endl; 181 #endif 162 182 163 183 /* … … 175 195 // usleep(1); 176 196 197 #ifdef DEBUG 177 198 cout << "MsgQueue::PostMsg: Returning rc = " << hex << rc << endl; 199 #endif 178 200 return rc; 179 201 }
Note:
See TracChangeset
for help on using the changeset viewer.