Changeset 3718 in Sophya for trunk/SophyaLib/SysTools/zthread.cc
- Timestamp:
- Dec 28, 2009, 10:05:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SysTools/zthread.cc
r3619 r3718 63 63 { 64 64 ZThread * thr = (ZThread *)xthr; 65 if(thr->_status == 1) thr->_status = 2;65 if(thr->_status == 2) thr->_status = 3; 66 66 return; 67 67 } … … 76 76 /* ------ Classe ZThread ------- */ 77 77 /*! 78 Constructor, with optional specification of the thread stack size. 78 Constructor, with optional specification of the thread stack size in bytes. 79 if not specified or zero, defaut system stack size is used. 79 80 */ 80 81 ZThread::ZThread(size_t stacksize) 81 82 { 82 83 _status = 0; 84 _fgstarted = false; 83 85 _ssize = 0; 84 86 _act = NULL; … … 93 95 94 96 /*! 95 Method which starts the thread. 97 Method which starts the thread. 98 The thread object is created by a call to pthread_create() in this method. 96 99 */ 97 100 void ZThread::start() 98 101 { 99 if ( IfStarted() ) throw ZThreadExc("ZThread::Start() - Already started thread !"); 102 if ( _fgstarted ) throw ZThreadExc("ZThread::Start() - Already started thread !"); 103 _fgstarted = true; 104 _status = 1; 100 105 int rc; 101 106 pthread_attr_t tha; … … 154 159 { 155 160 if (_act) _act(_usp); 156 setRC(0);161 exit(0); 157 162 return; 158 163 } … … 165 170 void ZThread::run_p() 166 171 { 167 _status = 1;172 _status = 2; 168 173 pthread_cleanup_push(zthr_cleanup, (void *)this); 169 174 run(); 170 _status = 2;175 _status = 3; 171 176 pthread_exit(&(_rc)); 172 177 pthread_cleanup_pop(0); … … 212 217 213 218 /*! 214 Constructor: Creates a associated pair of POSIX \c pthread_mutex_t219 Constructor: Creates an associated pair of POSIX \c pthread_mutex_t 215 220 and \c pthread_cond_t objects 216 221 \param : if fgd == true , the destructor call pthread_mutex_destroy/pthread_cond_destroy
Note:
See TracChangeset
for help on using the changeset viewer.